class Axiom::Aggregate

Abstract class for aggregate functions

Public Class Methods

default() click to toggle source

Return the default accumulator

@example

default = Aggregate.default

@return [Object]

@api public

# File lib/axiom/aggregate.rb, line 18
def self.default
  self::DEFAULT
end
finalize(accumulator) click to toggle source

Returns the value extracted from the accumulator

Default behaviour is to pass-through the accumulator

@example

value = Aggregate.finalize(accumulator)

@return [Object]

@api public

# File lib/axiom/aggregate.rb, line 32
def self.finalize(accumulator)
  accumulator
end

Public Instance Methods

call(accumulator, tuple) click to toggle source

Evaluate the aggregate using the provided Tuple

@example

accumulator = aggregate.call(accumulator, tuple)

@param [Object] accumulator

@param [Tuple] tuple

@return [Object]

@api public

# File lib/axiom/aggregate.rb, line 60
def call(accumulator, tuple)
  self.class.call(accumulator, value(tuple))
end
default() click to toggle source

Return the default for this aggregate

@example

default = aggregate.default

@return [Object]

@api public

# File lib/axiom/aggregate.rb, line 44
def default
  self.class.default
end
finalize(accumulator) click to toggle source

Finalize the accumulator value

@example

value = aggregate.finalize(accumulator)

@return [Object]

@api public

# File lib/axiom/aggregate.rb, line 72
def finalize(accumulator)
  self.class.finalize(accumulator)
end

Private Instance Methods

value(tuple) click to toggle source

Extract the value from the operand or tuple

@param [Tuple] tuple

the tuple to pass in to the operand if it responds to #call

@return [Object]

@api private

# File lib/axiom/aggregate.rb, line 86
def value(tuple)
  Function.extract_value(operand, tuple)
end