Evaluating a dotted quad IP address has clumsy use of inject/fold
The correct Ruby-way (also Perl and others) is to use pack/unpack, since low-level bytes job is what they are implemented for.

def dotted_ip_to_num ip
    ip.split(".").map(&amp;:to_i).pack("C*").unpack("N")[0]
end