Sha256: c128ad81fe7a66fe3896480b0f4892cb1112227c593139213ba16bde57ea685f

Contents?: true

Size: 540 Bytes

Versions: 52

Compression:

Stored size: 540 Bytes

Contents

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

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

      # Keep memo+val as new value
      def _happens(memo, val) 
        memo + (val.nil? ? 0 : val)
      end

    end # class Sum

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

  end # class Summarizer
end # module Bmg

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
bmg-0.23.3 lib/bmg/summarizer/sum.rb
bmg-0.23.2 lib/bmg/summarizer/sum.rb
bmg-0.23.1 lib/bmg/summarizer/sum.rb
bmg-0.23.0 lib/bmg/summarizer/sum.rb
bmg-0.21.5 lib/bmg/summarizer/sum.rb
bmg-0.21.4 lib/bmg/summarizer/sum.rb
bmg-0.20.5 lib/bmg/summarizer/sum.rb
bmg-0.19.3 lib/bmg/summarizer/sum.rb
bmg-0.21.3 lib/bmg/summarizer/sum.rb
bmg-0.21.2 lib/bmg/summarizer/sum.rb
bmg-0.21.0 lib/bmg/summarizer/sum.rb
bmg-0.20.4 lib/bmg/summarizer/sum.rb
bmg-0.20.2 lib/bmg/summarizer/sum.rb
bmg-0.20.1 lib/bmg/summarizer/sum.rb
bmg-0.20.0 lib/bmg/summarizer/sum.rb
bmg-0.19.2 lib/bmg/summarizer/sum.rb
bmg-0.19.1 lib/bmg/summarizer/sum.rb
bmg-0.19.0 lib/bmg/summarizer/sum.rb
bmg-0.18.15 lib/bmg/summarizer/sum.rb
bmg-0.18.14 lib/bmg/summarizer/sum.rb