Class: GridGenerator::Svg::PathCommand
- Inherits:
-
Object
- Object
- GridGenerator::Svg::PathCommand
show all
- Defined in:
- lib/grid_generator/svg/path_command.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(points: []) ⇒ PathCommand
Returns a new instance of PathCommand.
4
5
6
|
# File 'lib/grid_generator/svg/path_command.rb', line 4
def initialize(points: [])
@points = points
end
|
Instance Attribute Details
#points ⇒ Object
Returns the value of attribute points.
8
9
10
|
# File 'lib/grid_generator/svg/path_command.rb', line 8
def points
@points
end
|
Instance Method Details
#+(offset) ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'lib/grid_generator/svg/path_command.rb', line 14
def +(offset)
if offset.class == Matrix
new_points = points.map { |p| p + offset }
self.class.new(points: new_points)
else
raise ArgumentError, "Offset must be Matrix"
end
end
|
#==(other) ⇒ Object
23
24
25
|
# File 'lib/grid_generator/svg/path_command.rb', line 23
def ==(other)
self.class == other.class && self.points == other.points
end
|
#to_s ⇒ Object
27
28
29
|
# File 'lib/grid_generator/svg/path_command.rb', line 27
def to_s
[type, points_string].join(' ')
end
|
#type ⇒ Object
10
11
12
|
# File 'lib/grid_generator/svg/path_command.rb', line 10
def type
'M'
end
|