class TTFunk::Sum

Sum aggreaget. Is sums all pushed values.

Attributes

value[R]

Value

@return [#+]

Public Class Methods

new(init_value = 0) click to toggle source

@param init_value [#+] initial value

Calls superclass method
# File lib/ttfunk/sum.rb, line 12
def initialize(init_value = 0)
  super()
  @value = init_value
end

Public Instance Methods

<<(operand) click to toggle source

Push a value. It will be added to the current value.

@param operand [any] @return [void]

# File lib/ttfunk/sum.rb, line 21
def <<(operand)
  @value += coerce(operand)
end
value_or(_default) click to toggle source

Get the stored value or default.

@param _default [any] Unused. Here for API compatibility. @return [any]

# File lib/ttfunk/sum.rb, line 29
def value_or(_default)
  # value should always be non-nil
  value
end