Implementation of population count in pure ruby