Class: Summarizer
- Inherits:
-
Object
- Object
- Summarizer
- Defined in:
- lib/summarizer.rb
Constant Summary collapse
- MERGE_WITH_PLUS =
-> (_k, o, n) { o + n }
Instance Method Summary collapse
-
#initialize(collection, options = {}) ⇒ Summarizer
constructor
A new instance of Summarizer.
- #reduce(inital_state, &block) ⇒ Object
Constructor Details
#initialize(collection, options = {}) ⇒ Summarizer
Returns a new instance of Summarizer.
4 5 6 7 |
# File 'lib/summarizer.rb', line 4 def initialize(collection, = {}) @collection = collection @merge_type = [:merge_type] || MERGE_WITH_PLUS end |
Instance Method Details
#reduce(inital_state, &block) ⇒ Object
9 10 11 |
# File 'lib/summarizer.rb', line 9 def reduce(inital_state, &block) @collection.reduce(inital_state, &merge_step(block)) end |