Created
June 1, 2010 02:55
-
-
Save s0what/420509 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "ipaddr" | |
def ip2int(ip) | |
IPAddr.new(ip).to_i | |
end | |
def int2ip(int) | |
IPAddr.new(int, Socket::AF_INET).to_s | |
end | |
def ip_without_last(ip) | |
ip.gsub(/\.[0-9]{1,3}$/, ".*") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment