Skip to content

Instantly share code, notes, and snippets.

@s7ephen
Created July 21, 2011 18:43
Show Gist options
  • Save s7ephen/1097875 to your computer and use it in GitHub Desktop.
Save s7ephen/1097875 to your computer and use it in GitHub Desktop.
inet_aton inet_ntoa in Ruby
>> VERSION
=> "1.8.7"
>> require 'ipaddr'
=> true
>> IPAddr.new("10.0.0.1").to_i
=> 167772161
>> IPAddr.new(167772161, Socket::AF_INET).to_s
=> "10.0.0.1"
>> # To look around to find this, its just a matter of:
>> IPAddr.new("10.0.0.1").methods
=> ["inspect", "to_range", "<<", .........
..............
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment