class Instrumental::EventAggregator
Attributes
counts[RW]
frequency[RW]
received_at[RW]
values[RW]
Public Class Methods
new(frequency:)
click to toggle source
# File lib/instrumental/event_aggregator.rb, line 5 def initialize(frequency:) @values = Hash.new @frequency = frequency end
Public Instance Methods
coerce_time(time)
click to toggle source
# File lib/instrumental/event_aggregator.rb, line 23 def coerce_time(time) itime = time.to_i (itime - (itime % frequency)).to_i end
put(command)
click to toggle source
# File lib/instrumental/event_aggregator.rb, line 10 def put(command) command_at = command.time unless(command_at % frequency == 0) command.time = (command_at - (command_at % frequency)) end metadata = command.metadata @values[metadata] = (command + @values[metadata]) end
size()
click to toggle source
# File lib/instrumental/event_aggregator.rb, line 19 def size @values.size end