Method: NetAddr::IPv6#cmp
- Defined in:
- lib/ipv6.rb
#cmp(other) ⇒ Object
cmp compares equality with another IPv6. Return:
-
1 if this IPv6 is numerically greater
-
0 if the two are equal
-
-1 if this IPv6 is numerically less
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ipv6.rb', line 31 def cmp(other) if (!other.kind_of?(IPv6)) raise ArgumentError, "Expected an IPv6 object for 'other' but got a #{other.class}." end if (self.addr > other.addr) return 1 elsif (self.addr < other.addr) return -1 end return 0 end |