Class: LogfileInterval::Aggregator::Delta
- Defined in:
- lib/logfile_interval/aggregator/delta.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #add(value, group_by_value = nil) ⇒ Object
-
#initialize(options = {}) ⇒ Delta
constructor
A new instance of Delta.
- #val(k) ⇒ Object
Methods inherited from Base
Methods included from Registrar
#aggregator_classes, #all, #exist?, #inherited, #klass, #register_aggregator
Constructor Details
Instance Method Details
#add(value, group_by_value = nil) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/logfile_interval/aggregator/delta.rb', line 9 def add(value, group_by_value = nil) if @previous.has_key?(key(group_by_value)) @val.add(key(group_by_value), value - @previous[key(group_by_value)]) @size.increment(key(group_by_value)) end @previous.set(key(group_by_value), value) end |
#val(k) ⇒ Object
17 18 19 |
# File 'lib/logfile_interval/aggregator/delta.rb', line 17 def val(k) average(k) end |