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