class Tabs::Metrics::Counter::Stats
Attributes
period[R]
resolution[R]
values[R]
Public Class Methods
new(period, resolution, values)
click to toggle source
# File lib/tabs/metrics/counter/stats.rb, line 11 def initialize(period, resolution, values) @period, @resolution, @values = period, resolution, values end
Public Instance Methods
avg()
click to toggle source
# File lib/tabs/metrics/counter/stats.rb, line 35 def avg return 0 if values.size.zero? (self.total.to_f / values.size.to_f).round(Config.decimal_precision) end
each(&block)
click to toggle source
# File lib/tabs/metrics/counter/stats.rb, line 40 def each(&block) values.each(&block) end
first()
click to toggle source
# File lib/tabs/metrics/counter/stats.rb, line 15 def first values.first end
last()
click to toggle source
# File lib/tabs/metrics/counter/stats.rb, line 19 def last values.last end
max()
click to toggle source
# File lib/tabs/metrics/counter/stats.rb, line 31 def max @max ||= values.max_by { |v| v["count"] }["count"] end
min()
click to toggle source
# File lib/tabs/metrics/counter/stats.rb, line 27 def min @min ||= values.min_by { |v| v["count"] }["count"] end
to_a()
click to toggle source
# File lib/tabs/metrics/counter/stats.rb, line 44 def to_a values end
total()
click to toggle source
# File lib/tabs/metrics/counter/stats.rb, line 23 def total @total ||= values.map { |v| v["count"] }.sum end