Class: Alf::Aggregator::Concat
- Inherits:
-
Alf::Aggregator
- Object
- Alf::Aggregator
- Alf::Aggregator::Concat
- Defined in:
- lib/alf-aggregator/alf/aggregator/concat.rb
Overview
Defines a ‘concat()` aggregation operator.
Example:
# direct ruby usage
Alf::Aggregator.concat{ qty }.aggregate(...)
# lispy
(summarize :supplies, [:sid], :cat => concat{ qty })
Instance Attribute Summary
Attributes inherited from Alf::Aggregator
Instance Method Summary collapse
-
#_happens(memo, val) ⇒ Object
Aggregates on a tuple occurence.
-
#default_options ⇒ Object
Sets default options.
-
#finalize(memo) ⇒ Object
Finalizes computation.
-
#least ⇒ Object
Returns least value (defaults to “”).
Methods inherited from Alf::Aggregator
#==, #aggregate, coerce, #happens, #has_source_code!, #infer_type, inherited, #initialize, #to_lispy
Methods included from Support::Registry
#each, #listen, #listeners, #register, #registered
Constructor Details
This class inherits a constructor from Alf::Aggregator
Instance Method Details
#_happens(memo, val) ⇒ Object
Aggregates on a tuple occurence.
33 34 35 36 |
# File 'lib/alf-aggregator/alf/aggregator/concat.rb', line 33 def _happens(memo, val) memo << [:between].to_s unless memo.empty? memo << val.to_s end |
#default_options ⇒ Object
Sets default options.
19 20 21 |
# File 'lib/alf-aggregator/alf/aggregator/concat.rb', line 19 def {:before => "", :after => "", :between => ""} end |
#finalize(memo) ⇒ Object
Finalizes computation
41 42 43 |
# File 'lib/alf-aggregator/alf/aggregator/concat.rb', line 41 def finalize(memo) [:before].to_s + memo + [:after].to_s end |
#least ⇒ Object
Returns least value (defaults to “”)
26 27 28 |
# File 'lib/alf-aggregator/alf/aggregator/concat.rb', line 26 def least() "" end |