Sha256: cf76c0f5dfe05ae1353e0ca7e021dbae212a97875230c5904f2dd41e98b665b9
Contents?: true
Size: 971 Bytes
Versions: 1
Compression:
Stored size: 971 Bytes
Contents
module Tabs module Metrics class Value 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 count @count ||= values.map { |v| v["count"] }.sum end def sum @sum ||= values.map { |v| v["sum"] }.sum end def min @min ||= values.min_by { |v| v["min"] }["min"] end def max @max ||= values.max_by { |v| v["max"] }["max"] end def avg round_float(self.sum.to_f / self.count.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/value/stats.rb |