Class: PavementConditionIndex::Lookups::DeductValues
- Inherits:
-
Object
- Object
- PavementConditionIndex::Lookups::DeductValues
- Defined in:
- lib/pavement_condition_index/lookups/deduct_values.rb
Instance Method Summary collapse
- #call(value) ⇒ Object
-
#initialize(pavement_type: nil, severity: nil, distress_type: nil) ⇒ DeductValues
constructor
A new instance of DeductValues.
Constructor Details
#initialize(pavement_type: nil, severity: nil, distress_type: nil) ⇒ DeductValues
Returns a new instance of DeductValues.
5 6 7 8 9 |
# File 'lib/pavement_condition_index/lookups/deduct_values.rb', line 5 def initialize(pavement_type:nil,severity:nil,distress_type:nil) @pavement_type = pavement_type @severity = severity @distress_type = distress_type end |
Instance Method Details
#call(value) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/pavement_condition_index/lookups/deduct_values.rb', line 11 def call(value) deduct = PavementConditionIndex::Lookups::CalculatedDeductCoefficients::COEFFICIENTS[@pavement_type][@distress_type] coefficients = deduct[:coefficients][@severity] value = value.clamp(deduct[:valid_min],deduct[:valid_max]) # Asphalt charts use logarithmic scale, concrete uses linear value = deduct[:chart_type] == :log ? Math.log10(value.to_f) : value.to_f return evaluate_polynomial(*coefficients).call(value).clamp(0.0,100.0) end |