Sha256: 74d554062ff451db1d8a3db8f02a1893dcf1a334915800b6d01046e6e4b7c412

Contents?: true

Size: 674 Bytes

Versions: 13

Compression:

Stored size: 674 Bytes

Contents

module Alf
  class Aggregator
    #
    # Defines a `sum()` aggregation operator.
    #
    # Example:
    #
    #   # direct ruby usage
    #   Alf::Aggregator.sum{ qty }.aggregate(...)
    #
    #   # lispy 
    #   (summarize :supplies, [:sid], :total => sum{ qty })
    #
    class Sum < Aggregator

      # Returns 0 as least value.
      #
      # @see Aggregator::InstanceMethods#least
      def least()
        0
      end

      # Aggregates on a tuple occurence through `memo + val`
      #
      # @see Aggregator::InstanceMethods#_happens
      def _happens(memo, val) 
        memo + val
      end

    end # class Sum
  end # class Aggregator
end # module Alf

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
alf-core-0.16.3 lib/alf/aggregator/sum.rb
alf-core-0.16.2 lib/alf/aggregator/sum.rb
alf-core-0.16.1 lib/alf/aggregator/sum.rb
alf-core-0.16.0 lib/alf/aggregator/sum.rb
alf-core-0.15.0 lib/alf/aggregator/sum.rb
alf-core-0.14.0 lib/alf-aggregator/alf/aggregator/sum.rb
alf-core-0.13.1 lib/alf-aggregator/alf/aggregator/sum.rb
alf-core-0.13.0 lib/alf-aggregator/alf/aggregator/sum.rb
alf-0.12.2 lib/alf/aggregator/sum.rb
alf-0.12.1 lib/alf/aggregator/sum.rb
alf-0.12.0 lib/alf/aggregator/sum.rb
alf-0.11.1 lib/alf/aggregator/sum.rb
alf-0.11.0 lib/alf/aggregator/sum.rb