Skip to content

Instantly share code, notes, and snippets.

@kksudo
Forked from Lax/ipaddr_demo.rb
Last active August 29, 2015 14:25
Show Gist options
  • Save kksudo/658fa5b4987d301779c0 to your computer and use it in GitHub Desktop.
Save kksudo/658fa5b4987d301779c0 to your computer and use it in GitHub Desktop.
Ruby IPAddr class, inet_aton and inet_ntoa equivalence.
require 'ipaddr'
IPAddr.new("192.168.0.1").to_i
=> 3232235521
IPAddr.new(3232235521, Socket::AF_INET).to_s
=> "192.168.0.1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment