Class: GridGenerator::Cubic::SquareFactory
- Inherits:
-
Object
- Object
- GridGenerator::Cubic::SquareFactory
- Defined in:
- lib/grid_generator/cubic/square_factory.rb
Instance Attribute Summary collapse
-
#colour ⇒ Object
readonly
Returns the value of attribute colour.
-
#height_unit ⇒ Object
readonly
Returns the value of attribute height_unit.
-
#offset_unit ⇒ Object
readonly
Returns the value of attribute offset_unit.
-
#opacity ⇒ Object
readonly
Returns the value of attribute opacity.
-
#width_unit ⇒ Object
readonly
Returns the value of attribute width_unit.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
- #bottom_left ⇒ Object
- #bottom_right ⇒ Object
- #build ⇒ Object
-
#initialize(x:, y:, width_unit:, height_unit:, offset_unit:, face:) ⇒ SquareFactory
constructor
A new instance of SquareFactory.
- #points ⇒ Object
- #top_left ⇒ Object
- #top_right ⇒ Object
Constructor Details
#initialize(x:, y:, width_unit:, height_unit:, offset_unit:, face:) ⇒ SquareFactory
Returns a new instance of SquareFactory.
8 9 10 11 12 13 14 15 16 |
# File 'lib/grid_generator/cubic/square_factory.rb', line 8 def initialize(x:, y:, width_unit:, height_unit:, offset_unit:, face:) @x, @y = x, y @width_unit = width_unit @height_unit = height_unit @offset_unit = offset_unit face_attr = FaceParser.new(face).parse @colour = face_attr && face_attr[:colour] @opacity = face_attr && face_attr[:opacity] end |
Instance Attribute Details
#colour ⇒ Object (readonly)
Returns the value of attribute colour.
18 19 20 |
# File 'lib/grid_generator/cubic/square_factory.rb', line 18 def colour @colour end |
#height_unit ⇒ Object (readonly)
Returns the value of attribute height_unit.
18 19 20 |
# File 'lib/grid_generator/cubic/square_factory.rb', line 18 def height_unit @height_unit end |
#offset_unit ⇒ Object (readonly)
Returns the value of attribute offset_unit.
18 19 20 |
# File 'lib/grid_generator/cubic/square_factory.rb', line 18 def offset_unit @offset_unit end |
#opacity ⇒ Object (readonly)
Returns the value of attribute opacity.
18 19 20 |
# File 'lib/grid_generator/cubic/square_factory.rb', line 18 def opacity @opacity end |
#width_unit ⇒ Object (readonly)
Returns the value of attribute width_unit.
18 19 20 |
# File 'lib/grid_generator/cubic/square_factory.rb', line 18 def width_unit @width_unit end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
18 19 20 |
# File 'lib/grid_generator/cubic/square_factory.rb', line 18 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
18 19 20 |
# File 'lib/grid_generator/cubic/square_factory.rb', line 18 def y @y end |
Instance Method Details
#bottom_left ⇒ Object
32 33 34 |
# File 'lib/grid_generator/cubic/square_factory.rb', line 32 def bottom_left top_left + height_unit end |
#bottom_right ⇒ Object
28 29 30 |
# File 'lib/grid_generator/cubic/square_factory.rb', line 28 def bottom_right top_left + width_unit + height_unit end |
#build ⇒ Object
45 46 47 |
# File 'lib/grid_generator/cubic/square_factory.rb', line 45 def build GridGenerator::BaseElement.new(points: points, colour: colour, opacity: opacity) unless colour.nil? end |
#points ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/grid_generator/cubic/square_factory.rb', line 36 def points [ top_left, top_right, bottom_right, bottom_left, ] end |
#top_left ⇒ Object
20 21 22 |
# File 'lib/grid_generator/cubic/square_factory.rb', line 20 def top_left Matrix.column_vector([x, y]) + offset_unit end |
#top_right ⇒ Object
24 25 26 |
# File 'lib/grid_generator/cubic/square_factory.rb', line 24 def top_right top_left + width_unit end |