Sha256: 1da97eac8e5828c6985afcddffc566013153d2f9b6d77d4a16fd102c625d025d

Contents?: true

Size: 316 Bytes

Versions: 4

Compression:

Stored size: 316 Bytes

Contents

module Stages
  class Count < Stage
    def input
      result = Hash.new{ |h, k| h[k] = 0 }
      while v = source.run
        if v.is_a? Hash
          v.each_pair{ |key, value| result[key] += value }
        else
          result[v] += 1
        end
      end
      result.empty? ? nil : result
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
stages-0.3.0 lib/stages/count.rb
stages-0.2.10 lib/stages/count.rb
stages-0.2.9 lib/stages/count.rb
stages-0.2.8 lib/stages/count.rb