Class: GridGenerator::Svg::Polygon
- Inherits:
-
Object
- Object
- GridGenerator::Svg::Polygon
- Defined in:
- lib/grid_generator/svg/polygon.rb
Instance Attribute Summary collapse
-
#points ⇒ Object
readonly
Returns the value of attribute points.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
Instance Method Summary collapse
-
#initialize(points:, style:) ⇒ Polygon
constructor
A new instance of Polygon.
- #to_svg ⇒ Object
Constructor Details
#initialize(points:, style:) ⇒ Polygon
Returns a new instance of Polygon.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/grid_generator/svg/polygon.rb', line 4 def initialize(points: , style:) @points = case points when Array points.map { |p| "#{p[0,0].round},#{p[1,0].round}" }.join(' ') when String points else raise ArgumentError, "points must be Array or String" end @style = case style when GridGenerator::Svg::Style style.to_s when String style else raise ArgumentError, "style must be String or Style" end end |
Instance Attribute Details
#points ⇒ Object (readonly)
Returns the value of attribute points.
23 24 25 |
# File 'lib/grid_generator/svg/polygon.rb', line 23 def points @points end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
23 24 25 |
# File 'lib/grid_generator/svg/polygon.rb', line 23 def style @style end |
Instance Method Details
#to_svg ⇒ Object
25 26 27 |
# File 'lib/grid_generator/svg/polygon.rb', line 25 def to_svg "<polygon points=\"#{points}\" style=\"#{style.to_s}\" />" end |