Class: Bud::Avg

Inherits:
Agg
  • Object
show all
Defined in:
lib/bud/aggs.rb

Overview

:nodoc: all

Instance Method Summary (collapse)

Instance Method Details

- (Object) final(the_state)



184
185
186
# File 'lib/bud/aggs.rb', line 184

def final(the_state)
  the_state[0].to_f / the_state[1]
end

- (Object) init(val)



176
177
178
# File 'lib/bud/aggs.rb', line 176

def init(val)
  [val, 1]
end

- (Object) trans(the_state, val)



179
180
181
182
183
# File 'lib/bud/aggs.rb', line 179

def trans(the_state, val)
  retval = [the_state[0] + val]
  retval << (the_state[1] + 1)
  return retval, nil
end