===
is an alias of include? which returns true if ip address belongs to the range otherwise it returns false.to_i
then used to_s(2)
to convert the integer into binary form. Once we had the binary we counted the number of occurrence of digit 1 with count("1")
.