Class: Alf::Aggregator::Concat

Inherits:
Alf::Aggregator show all
Defined in:
lib/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

#functor, #options, #source

Instance Method Summary collapse

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.

See Also:

  • Aggregator::InstanceMethods#_happens

33
34
35
36
# File 'lib/alf/aggregator/concat.rb', line 33

def _happens(memo, val) 
  memo << options[:between].to_s unless memo.empty?
  memo << val.to_s
end

#default_optionsObject

Sets default options.

See Also:

  • Aggregator::InstanceMethods#default_options

19
20
21
# File 'lib/alf/aggregator/concat.rb', line 19

def default_options
  {:before => "", :after => "", :between => ""}
end

#finalize(memo) ⇒ Object

Finalizes computation

See Also:

  • Aggregator::InstanceMethods#finalize

41
42
43
# File 'lib/alf/aggregator/concat.rb', line 41

def finalize(memo)
  options[:before].to_s + memo + options[:after].to_s
end

#leastObject

Returns least value (defaults to “”)

See Also:

  • Aggregator::InstanceMethods#least

26
27
28
# File 'lib/alf/aggregator/concat.rb', line 26

def least()
  ""
end