Sha256: 166792b389acb31f3f4a10df8eaca42f4b524191a9d6e1c05839844fd52af700

Contents?: true

Size: 418 Bytes

Versions: 16

Compression:

Stored size: 418 Bytes

Contents

class Summarizer
  MERGE_WITH_PLUS =  -> (_k, o, n) { o + n }

  def initialize(collection, options = {})
    @collection = collection
    @merge_type =  options[:merge_type] || MERGE_WITH_PLUS
  end

  def reduce(inital_state, &block)
    @collection.reduce(inital_state, &merge_step(block))
  end

  private

  def merge_step(step_block)
    -> (state, i) { state.merge(step_block.call(i), &@merge_type) }
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
aleph_analytics-0.4.9.pre.dev lib/summarizer.rb
aleph_analytics-0.4.8 lib/summarizer.rb
aleph_analytics-0.4.7 lib/summarizer.rb
aleph_analytics-0.4.4 lib/summarizer.rb
aleph_analytics-0.4.2 lib/summarizer.rb
aleph_analytics-0.4.1 lib/summarizer.rb
aleph_analytics-0.3.0 lib/summarizer.rb
aleph_analytics-0.2.0 lib/summarizer.rb
aleph_analytics-0.1.0 lib/summarizer.rb
aleph_analytics-0.0.6 lib/summarizer.rb
aleph_analytics-0.0.5 lib/summarizer.rb
aleph_analytics-0.0.4 lib/summarizer.rb
aleph_analytics-0.0.3 lib/summarizer.rb
aleph_analytics-0.0.2 lib/summarizer.rb
aleph_analytics-0.0.1.alpha lib/summarizer.rb
aleph_analytics-0.0.0.alpha lib/summarizer.rb