Class: SorbetProgress::Calculator

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_metricsObject (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_percentagesObject (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

#totalObject (readonly)

Returns the value of attribute total.



10
11
12
# File 'lib/sorbet_progress/calculator.rb', line 10

def total
  @total
end