e$B$$$^$$$G$9!#e(B
r24388
e$B$G$9$,!"%M%C%H%^%9%/$,9MN8$5$l$F$$$J$$$N$G!"%"%I%l%9$,F1$8$G%M%Ce(B
e$B%H%^%9%/$,0c$&%*%V%8%’%/%[email protected]$H$_$J$5$l$F$7$^$$$^$9!#e(B
a1 = IPAddr.new(“192.168.2.0/24”)
=> #<IPAddr: IPv4:192.168.2.0/255.255.255.0>a2 = IPAddr.new(“192.168.2.0/25”)
=> #<IPAddr: IPv4:192.168.2.0/255.255.255.128>{a1 => ‘ipv4’, a2 => ‘ipv4’}.size
=> 1
e$B$3$l$i$OJL$NHO0O$r;X$9%*%V%8%’%/%[email protected]$H;W$&$N$G!"%O%C%7%e$N%-!<$H$7$F$Oe(B
e$BJL$N$b$N$G$"$k$H$&$l$7$$$G$9!#$H$j$"$($:%Q%C%A$G$9!#e(B
Nobuhiro IMAI [email protected]
Key fingerprint = F39E D552 545D 7C64 D690 F644 5A15 746C BD8E 7106
Index: lib/ipaddr.rb
— lib/ipaddr.rb (revision 24388)
+++ lib/ipaddr.rb (working copy)
@@ -338,7 +338,7 @@
Returns a hash value used by Hash, Set, and Array classes
def hash
- return (@addr.hash << 1) | (ipv4? ? 0 : 1)
- return ([@addr, @mask_addr].hash << 1) | (ipv4? ? 0 : 1)
end
Creates a Range object for the network address.
@@ -827,17 +827,19 @@
a4 = IPAddr.new(‘3ffe:505:2::1’)
a5 = IPAddr.new(‘127.0.0.1’)
a6 = IPAddr.new(’::1’)
- a7 = IPAddr.new(‘192.168.2.0/25’)
- a8 = IPAddr.new(‘192.168.2.0/25’)
- h = { a1 => ‘ipv4’, a2 => ‘ipv4’, a3 => ‘ipv6’, a4 => ‘ipv6’, a5 =>
‘ipv4’, a6 => ‘ipv6’ } - assert_equal(4, h.size)
-
h = { a1 => ‘ipv4’, a2 => ‘ipv4’, a3 => ‘ipv6’, a4 => ‘ipv6’, a5 =>
‘ipv4’, a6 => ‘ipv6’, a7 => ‘ipv4’, a8 => ‘ipv4’} -
assert_equal(5, h.size)
assert_equal(‘ipv4’, h[a1])
assert_equal(‘ipv4’, h[a2])
assert_equal(‘ipv6’, h[a3])
assert_equal(‘ipv6’, h[a4])require ‘set’
- s = Set[a1, a2, a3, a4, a5, a6]
- assert_equal(4, s.size)
- s = Set[a1, a2, a3, a4, a5, a6, a7, a8]
- assert_equal(5, s.size)
assert_equal(true, s.include?(a1))
assert_equal(true, s.include?(a2))
assert_equal(true, s.include?(a3))