Class: Axiom::Aggregate

Inherits:
Object
  • Object
show all
Includes:
AbstractType, Operation::Unary, Visitable
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 Visitable

#accept

Methods included from Operation::Unary

#initialize

Class Method Details

.defaultObject

Return the default accumulator

Examples:

default = Aggregate.default

Returns:

  • (Object)


21
22
23
# File 'lib/axiom/aggregate.rb', line 21

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)


35
36
37
# File 'lib/axiom/aggregate.rb', line 35

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)


63
64
65
# File 'lib/axiom/aggregate.rb', line 63

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

#defaultObject

Return the default for this aggregate

Examples:

default = aggregate.default

Returns:

  • (Object)


47
48
49
# File 'lib/axiom/aggregate.rb', line 47

def default
  self.class.default
end

#finalize(accumulator) ⇒ Object

Finalize the accumulator value

Examples:

value = aggregate.finalize(accumulator)

Returns:

  • (Object)


75
76
77
# File 'lib/axiom/aggregate.rb', line 75

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