Class: RubyReduce::Map
- Inherits:
-
Object
- Object
- RubyReduce::Map
- Defined in:
- lib/ruby_reduce/map.rb
Instance Method Summary collapse
- #emit(key, value) ⇒ Object
-
#initialize(reader_output, function) ⇒ Map
constructor
A new instance of Map.
- #map ⇒ Object
Constructor Details
#initialize(reader_output, function) ⇒ Map
Returns a new instance of Map.
3 4 5 6 7 |
# File 'lib/ruby_reduce/map.rb', line 3 def initialize(reader_output, function) @reader_output = reader_output @mapped_values = {} @function = function end |
Instance Method Details
#emit(key, value) ⇒ Object
9 10 11 12 |
# File 'lib/ruby_reduce/map.rb', line 9 def emit(key, value) @mapped_values[key] ||= [] @mapped_values[key] << value end |
#map ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/ruby_reduce/map.rb', line 14 def map @reader_output.each do |chunk| instance_exec chunk[0], chunk[1], &@function end @mapped_values end |