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.21.5 lib/bmg/summarizer/concat.rb
bmg-0.21.4 lib/bmg/summarizer/concat.rb
bmg-0.20.5 lib/bmg/summarizer/concat.rb
bmg-0.19.3 lib/bmg/summarizer/concat.rb
bmg-0.21.3 lib/bmg/summarizer/concat.rb
bmg-0.21.2 lib/bmg/summarizer/concat.rb
bmg-0.21.0 lib/bmg/summarizer/concat.rb
bmg-0.20.4 lib/bmg/summarizer/concat.rb
bmg-0.20.2 lib/bmg/summarizer/concat.rb
bmg-0.20.1 lib/bmg/summarizer/concat.rb
bmg-0.20.0 lib/bmg/summarizer/concat.rb
bmg-0.19.2 lib/bmg/summarizer/concat.rb
bmg-0.19.1 lib/bmg/summarizer/concat.rb
bmg-0.19.0 lib/bmg/summarizer/concat.rb
bmg-0.18.15 lib/bmg/summarizer/concat.rb
bmg-0.18.14 lib/bmg/summarizer/concat.rb
bmg-0.18.13 lib/bmg/summarizer/concat.rb
bmg-0.18.12 lib/bmg/summarizer/concat.rb
bmg-0.18.11 lib/bmg/summarizer/concat.rb
bmg-0.18.10 lib/bmg/summarizer/concat.rb