Class: GridGenerator::Svg::Path

Inherits:
Object
  • Object
show all
Defined in:
lib/grid_generator/svg/path.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(d:, style:) ⇒ Path

Returns a new instance of Path.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/grid_generator/svg/path.rb', line 4

def initialize(d: , style:)
  @d = case d
       when String
         d
       when Array
         d.map(&:to_s).join(' ')
       else
         raise ArgumentError, "d must be String or Array" 
       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

#dObject (readonly)

Returns the value of attribute d.



23
24
25
# File 'lib/grid_generator/svg/path.rb', line 23

def d
  @d
end

#styleObject (readonly)

Returns the value of attribute style.



23
24
25
# File 'lib/grid_generator/svg/path.rb', line 23

def style
  @style
end

Instance Method Details

#to_svgObject



25
26
27
# File 'lib/grid_generator/svg/path.rb', line 25

def to_svg
  "<path d=\"#{d}\" style=\"#{style}\" />"
end