lib/ipaddress_2/ipv4.rb in ipaddress_2-0.13.0 vs lib/ipaddress_2/ipv4.rb in ipaddress_2-0.14.0

- old
+ new

@@ -638,11 +638,11 @@ end # # Checks whether a subnet includes the given IP address. # - # Accepts an IPAddress::IPv4 object. + # Accepts an IPAddress::IPv4 object or a string. # # ip = IPAddress("192.168.10.100/24") # # addr = IPAddress("192.168.10.102/24") # @@ -650,23 +650,32 @@ # #=> true # # ip.include? IPAddress("172.16.0.48/16") # #=> false # + # ip.include? "192.168.10.50" + # #=> true + # def include?(oth) + unless oth.is_a? IPAddress::IPv4 + oth = IPv4.new(oth) + end @prefix <= oth.prefix and network_u32 == (oth.to_u32 & @prefix.to_u32) end # # Checks whether a subnet includes all the - # given IPv4 objects. + # given IPv4 objects or strings. # # ip = IPAddress("192.168.10.100/24") # # addr1 = IPAddress("192.168.10.102/24") # addr2 = IPAddress("192.168.10.103/24") # # ip.include_all?(addr1,addr2) + # #=> true + # + # ip.include_all?("192.168.10.102/24", "192.168.10.103/24") # #=> true # def include_all?(*others) others.all? {|oth| include?(oth)} end