Created
September 28, 2011 08:49
-
-
Save qsun/1247402 to your computer and use it in GitHub Desktop.
ruby integer to/from ip address
This file contains hidden or 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' | |
IPAddr.new('1.2.3.4').to_i | |
IPAddr.new(16909060, Socket::AF_INET).to_s | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For IP v6 use
Socket::AF_INET6
.