Sha256: 62742eac7797b0aea267d1455304abf5f8bc73479bae1911e83b1b5e2f4b03ca

Contents?: true

Size: 901 Bytes

Versions: 48

Compression:

Stored size: 901 Bytes

Contents

module Bmg
  class Summarizer
    #
    # String concatenation summarizer.
    #
    # Example:
    #
    #   # direct ruby usage
    #   Bmg::Summarizer.concat(:qty).summarize(...)
    #
    class Concat < Summarizer

      # Sets default options.
      def default_options
        {:before => "", :after => "", :between => ""}
      end

      # Returns least value (defaults to "")
      def least()
        ""
      end

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

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

    end # class Concat

    # Factors a concatenation summarizer
    def self.concat(*args, &bl)
      Concat.new(*args, &bl)
    end

  end # class Summarizer
end # module Bmg

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
bmg-0.18.9 lib/bmg/summarizer/concat.rb
bmg-0.18.8 lib/bmg/summarizer/concat.rb
bmg-0.18.7 lib/bmg/summarizer/concat.rb
bmg-0.18.6 lib/bmg/summarizer/concat.rb
bmg-0.18.5 lib/bmg/summarizer/concat.rb
bmg-0.18.4 lib/bmg/summarizer/concat.rb
bmg-0.18.3 lib/bmg/summarizer/concat.rb
bmg-0.18.2 lib/bmg/summarizer/concat.rb
bmg-0.18.1 lib/bmg/summarizer/concat.rb
bmg-0.18.0 lib/bmg/summarizer/concat.rb
bmg-0.17.8 lib/bmg/summarizer/concat.rb
bmg-0.17.7 lib/bmg/summarizer/concat.rb
bmg-0.17.6 lib/bmg/summarizer/concat.rb
bmg-0.17.5 lib/bmg/summarizer/concat.rb
bmg-0.17.4 lib/bmg/summarizer/concat.rb
bmg-0.17.3 lib/bmg/summarizer/concat.rb
bmg-0.17.2 lib/bmg/summarizer/concat.rb
bmg-0.16.7 lib/bmg/summarizer/concat.rb
bmg-0.17.1 lib/bmg/summarizer/concat.rb
bmg-0.17.0 lib/bmg/summarizer/concat.rb