Class: GridGenerator::Scaler

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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_scaleObject (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

#matrixObject (readonly)

Returns the value of attribute matrix.



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

def matrix
  @matrix
end

#vertical_scaleObject (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