Sha256: fd4f29054222de7065513d698fb814b4cfde22fc207f2723bd9d5adf9d1b28de

Contents?: true

Size: 764 Bytes

Versions: 19

Compression:

Stored size: 764 Bytes

Contents

module Mandy
  module Reducers
    class Base < Mandy::Task
      def self.compile(&blk)
        Class.new(Mandy::Reducers::Base) do 
          self.class_eval do
            define_method(:reducer, blk) if blk
          end
        end
      end
    
      def execute
        last_key, values = nil, []
        @input.each_line do |line|
           key, value = line.split(KEY_VALUE_SEPERATOR)
           value.chomp!
           last_key = key if last_key.nil?
           if key != last_key
             reducer(last_key, values)
             last_key, values = key, []
           end
           values << value
        end
        reducer(last_key, values)
      end
    
      private
    
      def reducer(key,values)
        #nil
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
trafficbroker-mandy-0.1.8 lib/reducers/base_reducer.rb
trafficbroker-mandy-0.1.9 lib/reducers/base_reducer.rb
trafficbroker-mandy-0.2.10 lib/reducers/base_reducer.rb
trafficbroker-mandy-0.2.11 lib/reducers/base_reducer.rb
trafficbroker-mandy-0.2.12 lib/reducers/base_reducer.rb
trafficbroker-mandy-0.2.2 lib/reducers/base_reducer.rb
trafficbroker-mandy-0.2.3 lib/reducers/base_reducer.rb
trafficbroker-mandy-0.2.4.2 lib/reducers/base_reducer.rb
trafficbroker-mandy-0.2.4.3 lib/reducers/base_reducer.rb
trafficbroker-mandy-0.2.4.4 lib/reducers/base_reducer.rb
trafficbroker-mandy-0.2.4.5 lib/reducers/base_reducer.rb
trafficbroker-mandy-0.2.4.6 lib/reducers/base_reducer.rb
trafficbroker-mandy-0.2.4 lib/reducers/base_reducer.rb
trafficbroker-mandy-0.2.5.1 lib/reducers/base_reducer.rb
trafficbroker-mandy-0.2.5 lib/reducers/base_reducer.rb
trafficbroker-mandy-0.2.6 lib/reducers/base_reducer.rb
trafficbroker-mandy-0.2.7 lib/reducers/base_reducer.rb
trafficbroker-mandy-0.2.8 lib/reducers/base_reducer.rb
trafficbroker-mandy-0.2 lib/reducers/base_reducer.rb