class Summarizer
Constants
- MERGE_WITH_PLUS
Public Class Methods
new(collection, options = {})
click to toggle source
# File lib/summarizer.rb, line 4 def initialize(collection, options = {}) @collection = collection @merge_type = options[:merge_type] || MERGE_WITH_PLUS end
Public Instance Methods
reduce(inital_state, &block)
click to toggle source
# File lib/summarizer.rb, line 9 def reduce(inital_state, &block) @collection.reduce(inital_state, &merge_step(block)) end
Private Instance Methods
merge_step(step_block)
click to toggle source
# File lib/summarizer.rb, line 15 def merge_step(step_block) -> (state, i) { state.merge(step_block.call(i), &@merge_type) } end