Sha256: e55bb9b4df25bf83eb6efd677fb3799a67fff2d1831c49f0facb265a3fb46447

Contents?: true

Size: 723 Bytes

Versions: 13

Compression:

Stored size: 723 Bytes

Contents

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

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

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

    end # class Max
  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/max.rb
alf-core-0.16.2 lib/alf/aggregator/max.rb
alf-core-0.16.1 lib/alf/aggregator/max.rb
alf-core-0.16.0 lib/alf/aggregator/max.rb
alf-core-0.15.0 lib/alf/aggregator/max.rb
alf-core-0.14.0 lib/alf-aggregator/alf/aggregator/max.rb
alf-core-0.13.1 lib/alf-aggregator/alf/aggregator/max.rb
alf-core-0.13.0 lib/alf-aggregator/alf/aggregator/max.rb
alf-0.12.2 lib/alf/aggregator/max.rb
alf-0.12.1 lib/alf/aggregator/max.rb
alf-0.12.0 lib/alf/aggregator/max.rb
alf-0.11.1 lib/alf/aggregator/max.rb
alf-0.11.0 lib/alf/aggregator/max.rb