summaryrefslogtreecommitdiff
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
parent6e6fd3ba1339461d03384852dcb70c2f27cec50f (diff)
downloadipaddress-bd5f741440529ca7aed72b0fcf772adc6c229b52.tar.gz
Reworked IPv4#include_all? method
-rw-r--r--CHANGELOG.rdoc3
-rw-r--r--README.rdoc9
-rw-r--r--lib/ipaddress/ipv4.rb13
-rw-r--r--test/ipaddress/ipv4_test.rb8
4 files changed, 27 insertions, 6 deletions
diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc
index cedfd88..05a0c52 100644
--- a/CHANGELOG.rdoc
+++ b/CHANGELOG.rdoc
@@ -1,6 +1,9 @@
== master
CHANGED:: IPAddress::IPv4#each_host to improve speed
+FIXED:: IPAddress::IPv4::summarize bug (summarization should now work properly)
+NEW:: IPAddress::IPv4#include_all?
+
== ipaddress 0.7.0
diff --git a/README.rdoc b/README.rdoc
index 1926944..33fce9a 100644
--- a/README.rdoc
+++ b/README.rdoc
@@ -921,10 +921,11 @@ Feel free to join us and tell us what you think!
== Thanks to
-Thanks to Luca Russo (vargolo) and Simone Carletti (weppos) for all
-the support and technical review. Thanks to Marco Beri, Bryan T. Richardson,
-Nicolas Fevrier, jdpace, Daniele Alessandri, jrdioko, Ghislain Charrier and
-Steve Rawlinson for their support, feedback and bug reports.
+Thanks to Luca Russo (vargolo), Erik Ahlström (eahlstrom) and Simone Carletti
+(weppos) for all the support and technical review. Thanks to Marco Beri,
+Bryan T. Richardson, Nicolas Fevrier, jdpace, Daniele Alessandri, jrdioko,
+Ghislain Charrier and Steve Rawlinson for their support, feedback and
+bug reports.
== Copyright
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
#
diff --git a/test/ipaddress/ipv4_test.rb b/test/ipaddress/ipv4_test.rb
index 968ff70..7d94144 100644
--- a/test/ipaddress/ipv4_test.rb
+++ b/test/ipaddress/ipv4_test.rb
@@ -240,6 +240,14 @@ class IPv4Test < Test::Unit::TestCase
assert_equal false, ip.include?(@klass.new("13.16.0.0/32"))
end
+ def test_method_include_all?
+ ip = @klass.new("192.168.10.100/24")
+ addr1 = @klass.new("192.168.10.102/24")
+ addr2 = @klass.new("192.168.10.103/24")
+ assert_equal true, ip.include_all?(addr1,addr2)
+ assert_equal false, ip.include_all?(addr1, @klass.new("13.16.0.0/32"))
+ end
+
def test_method_private?
assert_equal true, @klass.new("192.168.10.50/24").private?
assert_equal true, @klass.new("192.168.10.50/16").private?