Class: GridGenerator::DinoCube::Grid
- Inherits:
-
Object
- Object
- GridGenerator::DinoCube::Grid
- Defined in:
- lib/grid_generator/dino_cube/grid.rb
Instance Attribute Summary collapse
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
-
#units ⇒ Object
readonly
Returns the value of attribute units.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
-
#initialize(x:, y:, units:, elements:) ⇒ Grid
constructor
A new instance of Grid.
- #to_svg ⇒ Object
Constructor Details
#initialize(x:, y:, units:, elements:) ⇒ Grid
Returns a new instance of Grid.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/grid_generator/dino_cube/grid.rb', line 6 def initialize(x:, y:, units: , elements: ) @x, @y = x, y @units = units @elements = case elements when String FaceParser.new(elements).parse when Array elements else raise ArgumentError, "elements must be array or string" end end |
Instance Attribute Details
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
19 20 21 |
# File 'lib/grid_generator/dino_cube/grid.rb', line 19 def elements @elements end |
#units ⇒ Object (readonly)
Returns the value of attribute units.
19 20 21 |
# File 'lib/grid_generator/dino_cube/grid.rb', line 19 def units @units end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
19 20 21 |
# File 'lib/grid_generator/dino_cube/grid.rb', line 19 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
19 20 21 |
# File 'lib/grid_generator/dino_cube/grid.rb', line 19 def y @y end |
Instance Method Details
#to_svg ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/grid_generator/dino_cube/grid.rb', line 21 def to_svg output = '' element_shapes.each { |element| output += element.to_svg if element } output end |