ruby / ipaddr

A class to manipulate an IP address

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Proposal to add subnet information to the to_string method.

krpk1900 opened this issue · comments

Thank you for the great gem.

The inspect method contains subnet information and it seemed more natural to the developer that the to_string method should also contain the same subnet information.

So how about adding subnet information to the to_string method?

【Now】

ipaddr = IPAddr.new("192.168.2.0/24")

ipaddr.inspect
=> "#<IPAddr: IPv4:192.168.2.0/255.255.255.0>"
ipaddr.to_s
=> "192.168.2.0"
ipaddr.to_string
=> "192.168.2.0"

【My Proposal】

ipaddr = IPAddr.new("192.168.2.0/24")

ipaddr.inspect
=> "#<IPAddr: IPv4:192.168.2.0/255.255.255.0>"
ipaddr.to_s
=> "192.168.2.0"
ipaddr.to_string
=> "192.168.2.0/24"

Related proposal:

Thank you.👍