module BitsCount::File
Public Class Methods
bits_count(path)
click to toggle source
# File lib/bits_count/file.rb, line 21 def bits_count(path) f_size = ::File.size(path) bit1_count = population_count(path) { bit0_count: f_size*8 - bit1_count, bit1_count: bit1_count } end
population_count(path, alg = :str)
click to toggle source
# File lib/bits_count/file.rb, line 6 def population_count(path, alg = :str) ::File.open(path, "rb") do |f| case alg when :int32 IO.population_count_int32(f) when :str IO.population_count_str(f) when :map IO.population_count_map(f) else raise NotImplementedError, "#{alg} algorithm is not implemented" end end end