Class: GridGenerator::Cubic::FacingSquareFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/grid_generator/cubic/facing_square_factory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x:, y:, width:, height:, colour:, opacity:) ⇒ FacingSquareFactory

Returns a new instance of FacingSquareFactory.



6
7
8
9
10
# File 'lib/grid_generator/cubic/facing_square_factory.rb', line 6

def initialize(x: , y:, width:, height:, colour:, opacity:)
  @x, @y = x, y
  @width, @height = width, height
  @colour, @opacity = colour, opacity
end

Instance Attribute Details

#colourObject (readonly)

Returns the value of attribute colour.



12
13
14
# File 'lib/grid_generator/cubic/facing_square_factory.rb', line 12

def colour
  @colour
end

#heightObject (readonly)

Returns the value of attribute height.



12
13
14
# File 'lib/grid_generator/cubic/facing_square_factory.rb', line 12

def height
  @height
end

#opacityObject (readonly)

Returns the value of attribute opacity.



12
13
14
# File 'lib/grid_generator/cubic/facing_square_factory.rb', line 12

def opacity
  @opacity
end

#widthObject (readonly)

Returns the value of attribute width.



12
13
14
# File 'lib/grid_generator/cubic/facing_square_factory.rb', line 12

def width
  @width
end

#xObject (readonly)

Returns the value of attribute x.



12
13
14
# File 'lib/grid_generator/cubic/facing_square_factory.rb', line 12

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



12
13
14
# File 'lib/grid_generator/cubic/facing_square_factory.rb', line 12

def y
  @y
end

Instance Method Details

#buildObject



31
32
33
# File 'lib/grid_generator/cubic/facing_square_factory.rb', line 31

def build
  GridGenerator::BaseElement.new(points: points, colour: colour, opacity: opacity)
end

#max_xObject



14
15
16
# File 'lib/grid_generator/cubic/facing_square_factory.rb', line 14

def max_x
  x + width 
end

#max_yObject



18
19
20
# File 'lib/grid_generator/cubic/facing_square_factory.rb', line 18

def max_y
  y + height 
end

#pointsObject



22
23
24
25
26
27
28
29
# File 'lib/grid_generator/cubic/facing_square_factory.rb', line 22

def points
  [
    Matrix.column_vector([ x, y ]),
    Matrix.column_vector([ max_x, y ]),
    Matrix.column_vector([ max_x, max_y ]),
    Matrix.column_vector([ x, max_y ])
  ]
end