From: "U.Nakamura" Date: 2007-03-22T11:23:08+09:00 Subject: Re: Extensions to ipaddr.rb Hello, In message "Extensions to ipaddr.rb" on Mar.21,2007 19:11:10, wrote: | I'd like to contribute the following extensions to ipaddr.rb | | They allow the following constructs: | | puts IPAddr.new("192.168.0.0") + 1 # => 192.168.0.1 | puts IPAddr.new("192.168.0.0") - 1 # => 192.167.255.255 | puts IPAddr.new("192.168.0.0/24").netmask # => 255.255.255.0 | puts IPAddr.new("192.168.0.0/24").prefixlen # => 24 | puts IPAddr.new("192.168.0.0/24").size # => 256 Hmm, I have two more suggestions (sorry, without patch). * IPAddr#succ (and IPAddr#succ!) addr = IPAddr.new("192.168.0.0") puts addr.succ # => 192.168.0.1 * IPAddr#<=> addr1 = IPAddr.new("192.168.0.1") addr2 = addr1.succ puts addr1 <=> addr2 # => -1 puts addr1 <=> addr1 # => 0 puts addr2 <=> addr1 # => 1 If these two methods added, we will be able to use Range of IPAddr like this... for addr in IPAddr.new("192.168.0.1")..IPAddr.new("192.168.0.254") puts addr end Regards, -- U.Nakamura