Sha256: 74b26ec2c46558e61a6c7bdc8410232b0fde52186faeae9495891b22dcfc170e
Contents?: true
Size: 904 Bytes
Versions: 1
Compression:
Stored size: 904 Bytes
Contents
module Tabs module Metrics class Counter class Stats include Enumerable include Helpers attr_reader :period, :resolution, :values def initialize(period, resolution, values) @period, @resolution, @values = period, resolution, values end def first values.first end def last values.last end def total @total ||= values.map { |v| v["count"] }.sum end def min @min ||= values.min_by { |v| v["count"] }["count"] end def max @max ||= values.max_by { |v| v["count"] }["count"] end def avg round_float(self.total.to_f / values.size.to_f) end def each(&block) values.each(&block) end def to_a values end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tabs-0.8.0 | lib/tabs/metrics/counter/stats.rb |