summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorbluemonk <ceresa@gmail.com>2011-03-27 15:20:19 +0200
committerbluemonk <ceresa@gmail.com>2011-03-27 15:20:19 +0200
commitbd5f741440529ca7aed72b0fcf772adc6c229b52 (patch)
tree5d3f2849892ea9e0f78e3dfcee6b87e9a626fe47 /lib
parent6e6fd3ba1339461d03384852dcb70c2f27cec50f (diff)
downloadipaddress-bd5f741440529ca7aed72b0fcf772adc6c229b52.tar.gz
Reworked IPv4#include_all? method
Diffstat (limited to 'lib')
-rw-r--r--lib/ipaddress/ipv4.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/ipaddress/ipv4.rb b/lib/ipaddress/ipv4.rb
index 2333d9b..04c6ac9 100644
--- a/lib/ipaddress/ipv4.rb
+++ b/lib/ipaddress/ipv4.rb
@@ -537,10 +537,19 @@ module IPAddress;
end
#
- # Checks that all other IPAddress::IPv4 is included in this object
+ # Checks whether a subnet includes all the
+ # given IPv4 objects.
+ #
+ # 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
#
def include_all?(*others)
- others.find_all{|oth| include?(oth)}.length == others.length
+ others.all? {|oth| include?(oth)}
end
#