Class: LogfileInterval::Aggregator::Delta
- Defined in:
- lib/logfile_interval/aggregator/delta.rb
Instance Method Summary collapse
- #add(value, group_by = nil) ⇒ Object
-
#initialize ⇒ Delta
constructor
A new instance of Delta.
- #val(k) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize ⇒ Delta
Returns a new instance of Delta.
4 5 6 7 |
# File 'lib/logfile_interval/aggregator/delta.rb', line 4 def initialize @previous = Util::Counter.new super end |
Instance Method Details
#add(value, group_by = nil) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/logfile_interval/aggregator/delta.rb', line 9 def add(value, group_by = nil) if @previous.has_key?(key(group_by)) @val.add(key(group_by), @previous[key(group_by)] - value) @size.increment(key(group_by)) end @previous.set(key(group_by), value) end |
#val(k) ⇒ Object
17 18 19 |
# File 'lib/logfile_interval/aggregator/delta.rb', line 17 def val(k) average(k) end |