Class: PavementConditionIndex::PCI
- Inherits:
-
Object
- Object
- PavementConditionIndex::PCI
- Defined in:
- lib/pavement_condition_index/pci.rb
Instance Attribute Summary collapse
-
#score ⇒ Object
readonly
Returns the value of attribute score.
Instance Method Summary collapse
- #color ⇒ Object
-
#initialize(score: nil) ⇒ PCI
constructor
A new instance of PCI.
- #lookup ⇒ Object
- #rating ⇒ Object
Constructor Details
#initialize(score: nil) ⇒ PCI
Returns a new instance of PCI.
6 7 8 |
# File 'lib/pavement_condition_index/pci.rb', line 6 def initialize(score:nil) @score = score end |
Instance Attribute Details
#score ⇒ Object (readonly)
Returns the value of attribute score.
4 5 6 |
# File 'lib/pavement_condition_index/pci.rb', line 4 def score @score end |
Instance Method Details
#color ⇒ Object
37 38 39 |
# File 'lib/pavement_condition_index/pci.rb', line 37 def color lookup[:color] end |
#lookup ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pavement_condition_index/pci.rb', line 10 def lookup @lookup ||= begin case @score.to_i when 85..100 {rating: 'Good', color: '0f7d1d'} when 70..85 {rating: 'Satisfactory', color: '1ec734'} when 55..70 {rating: 'Fair', color: 'fefb4a'} when 40..55 {rating: 'Poor', color: 'fc2e1f'} when 25..40 {rating: 'Very Poor', color: 'a81a10'} when 10..25 {rating: 'Serious', color: '690d07'} when 0..10 {rating: 'Failed', color: '979797'} else {rating: 'ERROR', color: '000000'} end end end |
#rating ⇒ Object
33 34 35 |
# File 'lib/pavement_condition_index/pci.rb', line 33 def lookup[:rating] end |