Class: Axiom::Aggregate

Inherits:
Function show all
Includes:
Operation::Unary
Defined in:
lib/axiom/aggregate.rb,
lib/axiom/aggregate/sum.rb,
lib/axiom/aggregate/mean.rb,
lib/axiom/aggregate/count.rb,
lib/axiom/aggregate/maximum.rb,
lib/axiom/aggregate/minimum.rb,
lib/axiom/aggregate/variance.rb,
lib/axiom/aggregate/standard_deviation.rb

Overview

Abstract class for aggregate functions

Direct Known Subclasses

Count, Maximum, Mean, Minimum, Sum, Variance

Defined Under Namespace

Classes: Count, Maximum, Mean, Minimum, StandardDeviation, Sum, Variance

Instance Attribute Summary

Attributes included from Operation::Unary

#operand

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Operation::Unary

#initialize

Methods inherited from Function

extract_value, rename_attributes, #type

Methods included from Visitable

#accept

Class Method Details

.defaultObject

Return the default accumulator

Examples:

default = Aggregate.default

Returns:

  • (Object)


18
19
20
# File 'lib/axiom/aggregate.rb', line 18

def self.default
  self::DEFAULT
end

.finalize(accumulator) ⇒ Object

Returns the value extracted from the accumulator

Default behaviour is to pass-through the accumulator

Examples:

value = Aggregate.finalize(accumulator)

Returns:

  • (Object)


32
33
34
# File 'lib/axiom/aggregate.rb', line 32

def self.finalize(accumulator)
  accumulator
end

Instance Method Details

#call(accumulator, tuple) ⇒ Object

Evaluate the aggregate using the provided Tuple

Examples:

accumulator = aggregate.call(accumulator, tuple)

Parameters:

  • accumulator (Object)
  • tuple (Tuple)

Returns:

  • (Object)


60
61
62
# File 'lib/axiom/aggregate.rb', line 60

def call(accumulator, tuple)
  self.class.call(accumulator, value(tuple))
end

#defaultObject

Return the default for this aggregate

Examples:

default = aggregate.default

Returns:

  • (Object)


44
45
46
# File 'lib/axiom/aggregate.rb', line 44

def default
  self.class.default
end

#finalize(accumulator) ⇒ Object

Finalize the accumulator value

Examples:

value = aggregate.finalize(accumulator)

Returns:

  • (Object)


72
73
74
# File 'lib/axiom/aggregate.rb', line 72

def finalize(accumulator)
  self.class.finalize(accumulator)
end