Class: GridGenerator::Scaler
- Inherits:
-
Object
- Object
- GridGenerator::Scaler
- Defined in:
- lib/grid_generator/scaler.rb
Instance Attribute Summary collapse
-
#horizontal_scale ⇒ Object
readonly
Returns the value of attribute horizontal_scale.
-
#matrix ⇒ Object
readonly
Returns the value of attribute matrix.
-
#vertical_scale ⇒ Object
readonly
Returns the value of attribute vertical_scale.
Instance Method Summary collapse
-
#initialize(horizontal_scale: 1, vertical_scale: 1) ⇒ Scaler
constructor
A new instance of Scaler.
- #scale(point) ⇒ Object
Constructor Details
#initialize(horizontal_scale: 1, vertical_scale: 1) ⇒ Scaler
Returns a new instance of Scaler.
3 4 5 6 7 8 9 10 |
# File 'lib/grid_generator/scaler.rb', line 3 def initialize(horizontal_scale: 1, vertical_scale: 1) @horizontal_scale = horizontal_scale @vertical_scale = vertical_scale @matrix = Matrix[ [horizontal_scale,0], [0,vertical_scale] ] end |
Instance Attribute Details
#horizontal_scale ⇒ Object (readonly)
Returns the value of attribute horizontal_scale.
12 13 14 |
# File 'lib/grid_generator/scaler.rb', line 12 def horizontal_scale @horizontal_scale end |
#matrix ⇒ Object (readonly)
Returns the value of attribute matrix.
12 13 14 |
# File 'lib/grid_generator/scaler.rb', line 12 def matrix @matrix end |
#vertical_scale ⇒ Object (readonly)
Returns the value of attribute vertical_scale.
12 13 14 |
# File 'lib/grid_generator/scaler.rb', line 12 def vertical_scale @vertical_scale end |
Instance Method Details
#scale(point) ⇒ Object
14 15 16 |
# File 'lib/grid_generator/scaler.rb', line 14 def scale(point) matrix * point end |