From 7ec26d2a063ae39c25f17def9f6729615cc6f7d6 Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 8 Apr 2015 14:44:56 -0600 Subject: start to define path navigation. --- lib/scale/shapes/path.rb | 4 ++++ spec/shapes/path_spec.rb | 10 ++++++++++ 2 files changed, 14 insertions(+) create mode 100644 spec/shapes/path_spec.rb diff --git a/lib/scale/shapes/path.rb b/lib/scale/shapes/path.rb index ea5f7c7..484bd95 100644 --- a/lib/scale/shapes/path.rb +++ b/lib/scale/shapes/path.rb @@ -3,6 +3,10 @@ module Scale include Node attribute :d, String + def move_to(x:, y:) + self.d="M#{x} #{y}" + end + def xml_tag :path end diff --git a/spec/shapes/path_spec.rb b/spec/shapes/path_spec.rb new file mode 100644 index 0000000..377ec77 --- /dev/null +++ b/spec/shapes/path_spec.rb @@ -0,0 +1,10 @@ +describe Scale::Path do + it 'moves' do + subject.move_to(x: 10, y: 10) + expected = <<-XML + + + XML + expect(subject.to_xml).to eql(expected) + end +end -- cgit v1.2.3