Class: Instrumental::EventAggregator

Inherits:
Object
  • Object
show all
Defined in:
lib/instrumental/event_aggregator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(frequency:) ⇒ EventAggregator

Returns a new instance of EventAggregator.



5
6
7
8
# File 'lib/instrumental/event_aggregator.rb', line 5

def initialize(frequency:)
  @values = Hash.new
  @frequency = frequency
end

Instance Attribute Details

#countsObject

Returns the value of attribute counts.



3
4
5
# File 'lib/instrumental/event_aggregator.rb', line 3

def counts
  @counts
end

#frequencyObject

Returns the value of attribute frequency.



3
4
5
# File 'lib/instrumental/event_aggregator.rb', line 3

def frequency
  @frequency
end

#received_atObject

Returns the value of attribute received_at.



3
4
5
# File 'lib/instrumental/event_aggregator.rb', line 3

def received_at
  @received_at
end

#valuesObject

Returns the value of attribute values.



3
4
5
# File 'lib/instrumental/event_aggregator.rb', line 3

def values
  @values
end

Instance Method Details

#coerce_time(time) ⇒ Object



23
24
25
26
# File 'lib/instrumental/event_aggregator.rb', line 23

def coerce_time(time)
  itime = time.to_i
  (itime - (itime % frequency)).to_i
end

#put(command) ⇒ Object



10
11
12
13
14
15
16
17
# 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
   = command.
  @values[] = (command + @values[])
end

#sizeObject



19
20
21
# File 'lib/instrumental/event_aggregator.rb', line 19

def size
  @values.size
end