Replicating IPAddr functionality (from_u32)
Closed this issue · 4 comments
scollett commented
We store IP addresses in our database as integers. I am looking at replacing IPAddr with IPAddress, but I can not find a method to convert fixnum to dot notation. Does one exist? If not, is one on the roadmap?
The IPAddr way to achieve dot notation from integer:
IPAddr.new([fixnum], Socket::AF_INET).to_s
bluemonk commented
Hello Stephanie,
you may want to have a look at IPv4::parse_u32
http://rubydoc.info/gems/ipaddress/0.8.0/IPAddress/IPv4#parse_u32-class_method
It should do what you're looking for. Let me know if that's not what you want and I'll work something out for the next release.
bluemonk commented
Thank you mate :)
scollett commented
Perfect, thanks for the help! Looks like I can give IPAddr the boot.