Dear "E S",


thanks for you answer.

> Not really. There is no such IP address as 192.168.1.1/32. There's
> just the IP address 192.168.1.1 and the subnet it may be a part of.

So far I know it is a valid address.
I'm the opionion that nowadays a IP Address is only usefull for networking if 
you know the netmask too. So I handle write down IP's always as 
172.17.3.5/prefix_length, which could be also '32'. But sure I'm a admin, so 
I'm lazy. And in clear cases I don't write /32 at all.


> I understand the confusion, but the proper solution is not to change
> IPAddr to store your notation but to create two separate classes,
> IPAddr and Subnet (or CIDR or whatever). The reason for this is that
> any entity that needs to know what subnet should be used to interpret
> a given IP address should /already know/ what that subnet is.

Hmmm...
Maybe we think a bit different. I would use IPAddr for storing IPaddresses and 
get infomation based on this addresses, like Networkaddress aso.
(Why should I store the same thing twice, if I have already an object who 
knows about).

So I say it is still a failure that the IPAddress I gave to IPAddr is 
converted automatically to a different value.
And in anycase I state that  IPAddr, should reject wrong values and not change 
a value to different one.

I would like to have a clear interface. That does  things  the way, a user of 
the class expect.
----
ipaddr = IPAddr.new('192.168.0.3/24')
ipaddr.ip => 192.168.0.3
ipaddr.cidr => 192.168.0.3/24
ipaddr.prefix => 192.168.0.0/24
ipaddr.net => 192.168.0.0
ipaddr.mask => 255.255.255.0
ipaddr.prefix_length => 24
ipaddr.bc => 192.168.0.255 #IPv4 only If called on IPv6 it should raise an 
error.

Some more method (Brainstorming)
ipaddr.net_size? => 256
ipaddr.nodes_available? = 254 
# More methods ...

########
ipaddr = IPAddr.new('192.168.0.3/32')
ipaddr.ip => 192.168.0.3
ipaddr.cidr => 192.168.0.3/32
ipaddr.prefix => 192.168.0.3/32 or nil or rais an error # What is technical 
right and what would the user expect ? This is here the question. 

ipaddr.net => nil or rais an error? # I'm not sure at the moment
ipaddr.bc => same as above
ip.addr.mask => 255.255.255.255
ipaddr.prefix_length => 32


and so on
-----

A other Question: "What should the Class to with a /31 prefix IPv4?" 


IMHO this interface would fullfill both opinions  mentioned in this thread, 
and it is clean and don't do things, that are unexpectable.

regards

Markus