Class: SorbetProgress::Calculator
- Inherits:
-
Object
- Object
- SorbetProgress::Calculator
- Extended by:
- T::Sig
- Defined in:
- lib/sorbet_progress/calculator.rb
Overview
Computes the percentage stats for sigil metrics as well as other stats.
Instance Attribute Summary collapse
-
#coverage_metrics ⇒ Object
readonly
Returns the value of attribute coverage_metrics.
-
#sigil_percentages ⇒ Object
readonly
Returns the value of attribute sigil_percentages.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
-
#initialize(metrics) ⇒ Calculator
constructor
A new instance of Calculator.
Constructor Details
#initialize(metrics) ⇒ Calculator
Returns a new instance of Calculator.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/sorbet_progress/calculator.rb', line 13 def initialize(metrics) values = collect_values(sigil_breakdown_stats, metrics) @total = values.delete(:total_files) @sigil_percentages = values.map do |label, value| percentage = value * 1.0 / @total if @total && value { label: label, value: value, percentage: percentage } end @coverage_metrics = collect_values(coverage_stats, metrics) end |
Instance Attribute Details
#coverage_metrics ⇒ Object (readonly)
Returns the value of attribute coverage_metrics.
10 11 12 |
# File 'lib/sorbet_progress/calculator.rb', line 10 def coverage_metrics @coverage_metrics end |
#sigil_percentages ⇒ Object (readonly)
Returns the value of attribute sigil_percentages.
10 11 12 |
# File 'lib/sorbet_progress/calculator.rb', line 10 def sigil_percentages @sigil_percentages end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
10 11 12 |
# File 'lib/sorbet_progress/calculator.rb', line 10 def total @total end |