diff options
author | Michael Miller <icy.arctic.fox@gmail.com> | 2016-11-14 14:33:13 -0700 |
---|---|---|
committer | Romain Tartière <romain@blogreen.org> | 2017-08-30 09:13:22 +0200 |
commit | 548f00716f483876d00532bf76deec6c4171e9d6 (patch) | |
tree | e90e4ce1dc1c2588f6f9c32958b492a255815c21 | |
parent | 5a089bda5a9ff670751162092bd5853c30044d74 (diff) | |
download | ipaddress-548f00716f483876d00532bf76deec6c4171e9d6.tar.gz |
Implement unique_local? method
-rw-r--r-- | lib/ipaddress/ipv6.rb | 14 |
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 # |