Class: PavementConditionIndex::Lookups::CorrectedDeductValues
- Inherits:
-
Object
- Object
- PavementConditionIndex::Lookups::CorrectedDeductValues
- Defined in:
- lib/pavement_condition_index/lookups/corrected_deduct_values.rb
Instance Method Summary collapse
- #call(total_deduct_value) ⇒ Object
-
#initialize(pavement_type: nil, q: nil) ⇒ CorrectedDeductValues
constructor
A new instance of CorrectedDeductValues.
Constructor Details
#initialize(pavement_type: nil, q: nil) ⇒ CorrectedDeductValues
Returns a new instance of CorrectedDeductValues.
5 6 7 8 |
# File 'lib/pavement_condition_index/lookups/corrected_deduct_values.rb', line 5 def initialize(pavement_type:nil, q:nil) @pavement_type = pavement_type @q = "q#{q}".to_sym end |
Instance Method Details
#call(total_deduct_value) ⇒ Object
10 11 12 13 14 |
# File 'lib/pavement_condition_index/lookups/corrected_deduct_values.rb', line 10 def call(total_deduct_value) coefficients = PavementConditionIndex::Lookups::CalculatedCorrectedDeductCoefficients::COEFFICIENTS[@pavement_type][:coefficients][@q] total_deduct_value = total_deduct_value.clamp(0.0,200.0) return evaluate_polynomial(*coefficients).call(total_deduct_value).clamp(0.0,100.0) end |