Class: GridGenerator::RexCube::Grid

Inherits:
Object
  • Object
show all
Defined in:
lib/grid_generator/rex_cube/grid.rb

Direct Known Subclasses

LeftGrid, RightGrid, TopGrid

Instance Attribute Summary collapse

Instance Method Summary collapse

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/rex_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

#elementsObject (readonly)

Returns the value of attribute elements.



19
20
21
# File 'lib/grid_generator/rex_cube/grid.rb', line 19

def elements
  @elements
end

#unitsObject (readonly)

Returns the value of attribute units.



19
20
21
# File 'lib/grid_generator/rex_cube/grid.rb', line 19

def units
  @units
end

#xObject (readonly)

Returns the value of attribute x.



19
20
21
# File 'lib/grid_generator/rex_cube/grid.rb', line 19

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



19
20
21
# File 'lib/grid_generator/rex_cube/grid.rb', line 19

def y
  @y
end

Instance Method Details

#to_svgObject



21
22
23
24
25
26
27
# File 'lib/grid_generator/rex_cube/grid.rb', line 21

def to_svg
  output = ''

  element_shapes.each { |element| output += element.to_svg if element }

  output
end