lib/better_ipaddr/methods.rb in better_ipaddr-0.2.2 vs lib/better_ipaddr/methods.rb in better_ipaddr-0.2.3

- old
+ new

@@ -155,15 +155,17 @@ other.instance_variable_get(:@mask_addr) <=> @mask_addr end # Test the equality of two IP addresses, or an IP address an # integer representing an address in the same address family. + # + # Returns false for any other type. + # # @param other [IPAddr, Integer] the address to compare with # @return [Boolean] def ==(other) - return false if other.nil? - (self <=> other) == 0 + (other.is_a?(IPAddr) || other.is_a?(Integer)) && (self <=> other) == 0 end # The address at the given offset relative to the network address # of the network. A negative offset will be used to count # backwards from the highest addresses within the network.