Class: Shades::Aggregator

Inherits:
Object
  • Object
show all
Defined in:
lib/shades/cube.rb

Instance Method Summary collapse

Constructor Details

#initialize(query) ⇒ Aggregator

Returns a new instance of Aggregator.



152
153
154
155
# File 'lib/shades/cube.rb', line 152

def initialize(query)
  @query = query
  @state = {}
end

Instance Method Details

#add(event) ⇒ Object



157
158
159
160
161
162
163
164
# File 'lib/shades/cube.rb', line 157

def add(event)
  agg_event = AggEvent.new(@query, event)
  if @state.has_key?(agg_event.key)
    @state[event.key].add(agg_event)
  else
    @state[event.key] = agg_event
  end
end

#snapshotObject



166
167
168
# File 'lib/shades/cube.rb', line 166

def snapshot
  @state.values
end