Class: InciScore::Scorer
- Inherits:
-
Object
- Object
- InciScore::Scorer
- Defined in:
- lib/inci_score/scorer.rb
Constant Summary collapse
- HAZARD_RATIO =
25- WEIGHT_FACTOR =
5
Instance Attribute Summary collapse
-
#hazards ⇒ Object
readonly
Returns the value of attribute hazards.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(hazards) ⇒ Scorer
constructor
A new instance of Scorer.
Constructor Details
#initialize(hazards) ⇒ Scorer
Returns a new instance of Scorer.
10 11 12 13 14 |
# File 'lib/inci_score/scorer.rb', line 10 def initialize(hazards) @hazards = Array(hazards) @size = @hazards.size freeze end |
Instance Attribute Details
#hazards ⇒ Object (readonly)
Returns the value of attribute hazards.
8 9 10 |
# File 'lib/inci_score/scorer.rb', line 8 def hazards @hazards end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
8 9 10 |
# File 'lib/inci_score/scorer.rb', line 8 def size @size end |
Instance Method Details
#call ⇒ Object
16 17 18 19 |
# File 'lib/inci_score/scorer.rb', line 16 def call return 0 if hazards.empty? (100 - avg * HAZARD_RATIO).round(4) end |