Class: Instrumental::EventAggregator
- Inherits:
-
Object
- Object
- Instrumental::EventAggregator
- Defined in:
- lib/instrumental/event_aggregator.rb
Instance Attribute Summary collapse
-
#counts ⇒ Object
Returns the value of attribute counts.
-
#frequency ⇒ Object
Returns the value of attribute frequency.
-
#received_at ⇒ Object
Returns the value of attribute received_at.
-
#values ⇒ Object
Returns the value of attribute values.
Instance Method Summary collapse
- #coerce_time(time) ⇒ Object
-
#initialize(frequency:) ⇒ EventAggregator
constructor
A new instance of EventAggregator.
- #put(command) ⇒ Object
- #size ⇒ Object
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
#counts ⇒ Object
Returns the value of attribute counts.
3 4 5 |
# File 'lib/instrumental/event_aggregator.rb', line 3 def counts @counts end |
#frequency ⇒ Object
Returns the value of attribute frequency.
3 4 5 |
# File 'lib/instrumental/event_aggregator.rb', line 3 def frequency @frequency end |
#received_at ⇒ Object
Returns the value of attribute received_at.
3 4 5 |
# File 'lib/instrumental/event_aggregator.rb', line 3 def received_at @received_at end |
#values ⇒ Object
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 |
#size ⇒ Object
19 20 21 |
# File 'lib/instrumental/event_aggregator.rb', line 19 def size @values.size end |