Sha256: e2807d1f642e2d29daf719aafdcadbc40cb8ba09bd392f0b7a7d95fd5c6fee27

Contents?: true

Size: 707 Bytes

Versions: 25

Compression:

Stored size: 707 Bytes

Contents

module Bmg
  class Summarizer
    # See First and Last
    class Positional < Summarizer

      def initialize(*args, &block)
        super
        raise ArgumentError, "Missing order" unless options[:order]
        @ordering = Ordering.new(options[:order])
      end
      attr_reader :ordering

      def least
        nil
      end

      def happens(memo, tuple)
        if memo.nil?
          tuple
        else
          c = ordering.call(memo, tuple)
          c <= 0 ? choose(memo, tuple) : choose(tuple, memo)
        end
      end

      def finalize(memo)
        return nil if memo.nil?
        extract_value(memo)
      end

    end # class Positional
  end # class Summarizer
end # module Bmg

Version data entries

25 entries across 25 versions & 1 rubygems

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