Module: RailsVitals::Calculable
- Included in:
- DashboardController, HeatmapController, MCP::Tools::GetScore
- Defined in:
- lib/rails_vitals/calculable.rb
Instance Method Summary collapse
Instance Method Details
#average(records, method) ⇒ Object
3 4 5 6 7 |
# File 'lib/rails_vitals/calculable.rb', line 3 def average(records, method) return 0.0 if records.empty? (records.sum(&method).to_f / records.size).round(1) end |
#percentage(count, total) ⇒ Object
9 10 11 12 13 |
# File 'lib/rails_vitals/calculable.rb', line 9 def percentage(count, total) return 0.0 if total.zero? (count.to_f / total * 100).round(1) end |