Implementations of population count (Hamming weight in binary case) using pure ruby.
Add this line to your application's Gemfile:
gem 'bits_count'
And then execute:
$ bundle
Or install it yourself as:
$ gem install bits_count
Example: Calculate bits count in file
(in IRB)
require 'bits_count/irb_helper'
count_bits "path/to/some/file.jpg"