Sha256: d3e6acf79dc9d2efec0fa424234e4f35414fe0acf335709619fb68c15acb7164

Contents?: true

Size: 339 Bytes

Versions: 9

Compression:

Stored size: 339 Bytes

Contents

module Stages
  class Count < Stage
    def process
      result = Hash.new{ |h, k| h[k] = 0 }
      while !source_empty?
        v = source.run
        if v.is_a? Hash
          v.each_pair{ |key, value| result[key] += (value || 0) }
        else
          result[v] += 1
        end
      end
      handle_value result
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
stages-1.2.1 lib/stages/count.rb
stages-1.2.0 lib/stages/count.rb
stages-1.1.5 lib/stages/count.rb
stages-1.1.2 lib/stages/count.rb
stages-1.1.1 lib/stages/count.rb
stages-1.0.1 lib/stages/count.rb
stages-1.0.0 lib/stages/count.rb
stages-0.4.1 lib/stages/count.rb
stages-0.4.0 lib/stages/count.rb