summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Miller <icy.arctic.fox@gmail.com>2016-11-14 14:33:13 -0700
committerRomain Tartière <romain@blogreen.org>2017-08-30 09:13:22 +0200
commit548f00716f483876d00532bf76deec6c4171e9d6 (patch)
treee90e4ce1dc1c2588f6f9c32958b492a255815c21
parent5a089bda5a9ff670751162092bd5853c30044d74 (diff)
downloadipaddress-548f00716f483876d00532bf76deec6c4171e9d6.tar.gz
Implement unique_local? method
-rw-r--r--lib/ipaddress/ipv6.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/ipaddress/ipv6.rb b/lib/ipaddress/ipv6.rb
index 6850c03..1012d7d 100644
--- a/lib/ipaddress/ipv6.rb
+++ b/lib/ipaddress/ipv6.rb
@@ -436,6 +436,20 @@ module IPAddress;
[self.class.new("fe80::/64")].any? {|i| i.include? self}
end
+ #
+ # Checks if an IPv6 address objects belongs
+ # to a unique-local network RFC4193
+ #
+ # Example:
+ #
+ # ip = IPAddress "fc00::1"
+ # ip.unique_local?
+ # #=> true
+ #
+ def unique_local?
+ [self.class.new("fc00::/7")].any? {|i| i.include? self}
+ end
+
#
# Returns true if the address is a mapped address
#