diff options
author | Romain Tartière <romain@blogreen.org> | 2016-03-16 20:44:46 +0100 |
---|---|---|
committer | Romain Tartière <romain@blogreen.org> | 2016-03-16 20:44:46 +0100 |
commit | e5c9039420d0d38e066aa2f81c46cba698d7803a (patch) | |
tree | 7ef0d0139a09eb9ffa07d93b663ecca832ec5384 /lib | |
parent | 064502c6a943f983cabea38fccdb528ad9469aec (diff) | |
download | ipaddress-e5c9039420d0d38e066aa2f81c46cba698d7803a.tar.gz |
Fix <=> for IPv4 and IPv6.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ipaddress/ipv4.rb | 1 | ||||
-rw-r--r-- | lib/ipaddress/ipv6.rb | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/lib/ipaddress/ipv4.rb b/lib/ipaddress/ipv4.rb index 7d8e0d3..5e456f6 100644 --- a/lib/ipaddress/ipv4.rb +++ b/lib/ipaddress/ipv4.rb @@ -509,6 +509,7 @@ module IPAddress; # #=> ["10.100.100.1/8","10.100.100.1/16","172.16.0.1/16"] # def <=>(oth) + return nil unless oth.is_a?(self.class) return prefix <=> oth.prefix if to_u32 == oth.to_u32 to_u32 <=> oth.to_u32 end diff --git a/lib/ipaddress/ipv6.rb b/lib/ipaddress/ipv6.rb index 88098bc..e6e8d04 100644 --- a/lib/ipaddress/ipv6.rb +++ b/lib/ipaddress/ipv6.rb @@ -487,6 +487,7 @@ module IPAddress; # #=> ["2001:db8:1::1/64","2001:db8:1::1/65","2001:db8:2::1/64"] # def <=>(oth) + return nil unless oth.is_a?(self.class) return prefix <=> oth.prefix if to_u128 == oth.to_u128 to_u128 <=> oth.to_u128 end |