Sha256: d9624f16cb2a6e573f5c986c987591d5c43e614e29a4b3d4f581637773cb0c6c

Contents?: true

Size: 612 Bytes

Versions: 52

Compression:

Stored size: 612 Bytes

Contents

module Bmg
  class Summarizer
    #
    # Max summarizer.
    #
    # Example:
    #
    #   # direct ruby usage
    #   Bmg::Summarizer.max(:qty).summarize(...)
    #
    class Max < Summarizer

      # Returns nil as least value.
      def least()
        nil
      end

      # Keeps the maximum value between memo and val, ignoring nil
      def _happens(memo, val) 
        memo.nil? ? val : (val.nil? ? memo : (memo > val ? memo : val))
      end

    end # class Max

    # Factors a max summarizer
    def self.max(*args, &bl)
      Max.new(*args, &bl)
    end

  end # class Summarizer
end # module Bmg

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
bmg-0.18.13 lib/bmg/summarizer/max.rb
bmg-0.18.12 lib/bmg/summarizer/max.rb
bmg-0.18.11 lib/bmg/summarizer/max.rb
bmg-0.18.10 lib/bmg/summarizer/max.rb
bmg-0.18.9 lib/bmg/summarizer/max.rb
bmg-0.18.8 lib/bmg/summarizer/max.rb
bmg-0.18.7 lib/bmg/summarizer/max.rb
bmg-0.18.6 lib/bmg/summarizer/max.rb
bmg-0.18.5 lib/bmg/summarizer/max.rb
bmg-0.18.4 lib/bmg/summarizer/max.rb
bmg-0.18.3 lib/bmg/summarizer/max.rb
bmg-0.18.2 lib/bmg/summarizer/max.rb
bmg-0.18.1 lib/bmg/summarizer/max.rb
bmg-0.18.0 lib/bmg/summarizer/max.rb
bmg-0.17.8 lib/bmg/summarizer/max.rb
bmg-0.17.7 lib/bmg/summarizer/max.rb
bmg-0.17.6 lib/bmg/summarizer/max.rb
bmg-0.17.5 lib/bmg/summarizer/max.rb
bmg-0.17.4 lib/bmg/summarizer/max.rb
bmg-0.17.3 lib/bmg/summarizer/max.rb