Class: Axiom::Aggregate
- 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
Defined Under Namespace
Classes: Count, Maximum, Mean, Minimum, StandardDeviation, Sum, Variance
Instance Attribute Summary
Attributes included from Operation::Unary
Class Method Summary collapse
-
.default ⇒ Object
Return the default accumulator.
-
.finalize(accumulator) ⇒ Object
Returns the value extracted from the accumulator.
Instance Method Summary collapse
-
#call(accumulator, tuple) ⇒ Object
Evaluate the aggregate using the provided Tuple.
-
#default ⇒ Object
Return the default for this aggregate.
-
#finalize(accumulator) ⇒ Object
Finalize the accumulator value.
Methods included from Operation::Unary
Methods inherited from Function
extract_value, rename_attributes, #type
Methods included from Visitable
Class Method Details
.default ⇒ Object
Return the default accumulator
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
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
60 61 62 |
# File 'lib/axiom/aggregate.rb', line 60 def call(accumulator, tuple) self.class.call(accumulator, value(tuple)) end |
#default ⇒ Object
Return the default for this aggregate
44 45 46 |
# File 'lib/axiom/aggregate.rb', line 44 def default self.class.default end |
#finalize(accumulator) ⇒ Object
Finalize the accumulator value
72 73 74 |
# File 'lib/axiom/aggregate.rb', line 72 def finalize(accumulator) self.class.finalize(accumulator) end |