ipaddress-gem/ipaddress

Replicating IPAddr functionality (from_u32)

Closed this issue · 4 comments

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

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
I'm glad you are back :)

Thank you mate :)

Perfect, thanks for the help! Looks like I can give IPAddr the boot.