diff options
| author | mo khan <mo@mokhan.ca> | 2015-04-08 14:44:56 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-04-08 14:44:56 -0600 |
| commit | 7ec26d2a063ae39c25f17def9f6729615cc6f7d6 (patch) | |
| tree | 3f4fc0e3b07ef972fa9dbb84e9e8fed3fe790372 | |
| parent | 3aa864bebf493435d56ffa607d6c10db8a29c408 (diff) | |
start to define path navigation.
| -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 |
