Class: EncodingEstimator::RangeScale
- Inherits:
-
Object
- Object
- EncodingEstimator::RangeScale
- Defined in:
- lib/encoding_estimator/detector.rb
Overview
Represent a function the maps a value between min and max to 0..1
Instance Method Summary collapse
-
#initialize(min, max) ⇒ RangeScale
constructor
Initialize a new object from the range minimum and maximum.
-
#scale(value) ⇒ Float
Map the given value to a range between 0 and 1 (min is 0, max is 1).
Constructor Details
#initialize(min, max) ⇒ RangeScale
Initialize a new object from the range minimum and maximum
16 17 18 19 20 21 22 23 |
# File 'lib/encoding_estimator/detector.rb', line 16 def initialize( min, max ) @min = min @max = max if max == min @min = min - 1.0 end end |
Instance Method Details
#scale(value) ⇒ Float
Map the given value to a range between 0 and 1 (min is 0, max is 1)
30 31 32 |
# File 'lib/encoding_estimator/detector.rb', line 30 def scale( value ) ( value - @min ) / ( @max - @min ) end |