Class: CodeSunset::ScoreCalculator
- Inherits:
-
Object
- Object
- CodeSunset::ScoreCalculator
- Defined in:
- lib/code_sunset/score_calculator.rb
Instance Method Summary collapse
- #breakdown ⇒ Object
-
#initialize(feature:, snapshot:) ⇒ ScoreCalculator
constructor
A new instance of ScoreCalculator.
- #score ⇒ Object
Constructor Details
#initialize(feature:, snapshot:) ⇒ ScoreCalculator
Returns a new instance of ScoreCalculator.
3 4 5 6 |
# File 'lib/code_sunset/score_calculator.rb', line 3 def initialize(feature:, snapshot:) @feature = feature @snapshot = snapshot end |
Instance Method Details
#breakdown ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/code_sunset/score_calculator.rb', line 14 def breakdown return {} unless snapshot { recency: recency_breakdown, volume: volume_breakdown, orgs: org_breakdown, paid_usage: paid_usage_breakdown } end |
#score ⇒ Object
8 9 10 11 12 |
# File 'lib/code_sunset/score_calculator.rb', line 8 def score return 0.0 unless snapshot breakdown.values.sum { |component| component[:score] }.round(2) end |