Class: PavementConditionIndex::DistressGroup
- Inherits:
-
Object
- Object
- PavementConditionIndex::DistressGroup
- Defined in:
- lib/pavement_condition_index/distress_group.rb
Instance Attribute Summary collapse
-
#distresses ⇒ Object
readonly
Returns the value of attribute distresses.
-
#pavement_type ⇒ Object
readonly
Returns the value of attribute pavement_type.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
-
#size_of_sample_unit ⇒ Object
readonly
Returns the value of attribute size_of_sample_unit.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #deduct_value ⇒ Object
- #density ⇒ Object
- #density_percentage ⇒ Object
-
#initialize(type: nil, severity: nil, distresses: nil, size_of_sample_unit: nil, pavement_type: nil) ⇒ DistressGroup
constructor
A new instance of DistressGroup.
- #total_quantity ⇒ Object
Constructor Details
#initialize(type: nil, severity: nil, distresses: nil, size_of_sample_unit: nil, pavement_type: nil) ⇒ DistressGroup
Returns a new instance of DistressGroup.
7 8 9 10 11 12 13 |
# File 'lib/pavement_condition_index/distress_group.rb', line 7 def initialize(type:nil,severity:nil,distresses:nil,size_of_sample_unit:nil,pavement_type:nil) @type = type @severity = severity @distresses = distresses @size_of_sample_unit = size_of_sample_unit @pavement_type = pavement_type end |
Instance Attribute Details
#distresses ⇒ Object (readonly)
Returns the value of attribute distresses.
4 5 6 |
# File 'lib/pavement_condition_index/distress_group.rb', line 4 def distresses @distresses end |
#pavement_type ⇒ Object (readonly)
Returns the value of attribute pavement_type.
5 6 7 |
# File 'lib/pavement_condition_index/distress_group.rb', line 5 def pavement_type @pavement_type end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
4 5 6 |
# File 'lib/pavement_condition_index/distress_group.rb', line 4 def severity @severity end |
#size_of_sample_unit ⇒ Object (readonly)
Returns the value of attribute size_of_sample_unit.
5 6 7 |
# File 'lib/pavement_condition_index/distress_group.rb', line 5 def size_of_sample_unit @size_of_sample_unit end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/pavement_condition_index/distress_group.rb', line 4 def type @type end |
Instance Method Details
#deduct_value ⇒ Object
33 34 35 |
# File 'lib/pavement_condition_index/distress_group.rb', line 33 def deduct_value @deduct_value ||= PavementConditionIndex::Lookups::DeductValues.new(pavement_type: @pavement_type, distress_type: @type, severity: @severity).call(density_percentage) end |
#density ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/pavement_condition_index/distress_group.rb', line 19 def density @density ||= begin if @type == :joint_seal_damage 1.0 else total_quantity/@size_of_sample_unit.to_f end end end |
#density_percentage ⇒ Object
29 30 31 |
# File 'lib/pavement_condition_index/distress_group.rb', line 29 def density_percentage @density_percentage ||= density * 100 end |
#total_quantity ⇒ Object
15 16 17 |
# File 'lib/pavement_condition_index/distress_group.rb', line 15 def total_quantity @total_quantity ||= @distresses.map{|distress| distress[:quantity]}.reduce(:+) end |