From: bluemonk Date: 2010-06-08T16:53:23+09:00 Subject: Re: IPAddress: new IP manipulation library On Jun 7, 11:26 pm, "Aaron D. Gifford" wrote: > Without having looked at your library, does it support IP ranges (i.e. > blocks of IP addresses that are contiguous but do not necessarily > exactly match a subnet boundary)?   Perhaps as a separate class? Not yet, I plan to introduce ranges in 0.7.0, I'm still working on a meaningful notation. > Can one do this? > > ip = IPAddress.new("10.0.0.1") ## No prefix specified... will it > assume /32 IPv4 host prefix? No, it will assume the classful subnet mask (/8 in this case) http://marcoceresa.com/ipaddress/classes/IPAddress/IPv4.html#M000008 However this behaviour is currently under discussion, as it is one major break in respect to IPAddr (the other being #to_s). It may change in the future. > Also, are there methods to determine if a network (or range, if > supported) contains another IP, network, or range?  Something like: > > ip = IPAddress.new("10.0.0.1/32") > net = IPAddress.new("10.0.0.0/24") > puts "IP is contained by network" if net.contains?(ip) || ip.is_in?(net) Yes: http://marcoceresa.com/ipaddress/classes/IPAddress/IPv4.html#M000034 Regards, Marco