diff options
| -rw-r--r-- | lib/scale/shapes/path.rb | 4 | ||||
| -rw-r--r-- | spec/shapes/path_spec.rb | 10 |
2 files changed, 14 insertions, 0 deletions
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 version="1.0"?> +<path d="M10 10"/> + XML + expect(subject.to_xml).to eql(expected) + end +end |
