Sha256: 2ce4228b6ee3653c1016cf0282b6eb13d0033a820e813174f56a74b2c7aaf6a5
Contents?: true
Size: 767 Bytes
Versions: 1
Compression:
Stored size: 767 Bytes
Contents
require 'crosscounter/util' module Crosscounter module Compute extend self def compute(hashes, prop_a, prop_b = nil) count = 0 index = 0 length = hashes.length while index < length if hashes[index].member?(prop_a) && (!prop_b || hashes[index].member?(prop_b)) count += 1 end index += 1 end count end def compute_all(enumerable, rows, columns) setified = enumerable.map { |hash| Util.hashify(hash) } scolumns = Util.stringify(columns) Util.stringify(rows).map do |row| initial = [row, compute(setified, row)] scolumns.each do |col| initial << compute(setified, row, col) end initial end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
crosscounter-0.4.0 | lib/crosscounter/compute.rb |