Skip to content

Commit

Permalink
Merge pull request #93 from asomers/link_local
Browse files Browse the repository at this point in the history
Add IPv6#link_local?
  • Loading branch information
francisluong authored Aug 29, 2017
2 parents 7f68225 + 2edbae8 commit 580edc4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/ipaddress/ipv6.rb
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,13 @@ def compressed
@compressed
end

#
# Returns true if the address is a link local address
#
def link_local?
@groups[0] == 0xfe80
end

#
# Returns true if the address is an unspecified address
#
Expand Down
6 changes: 6 additions & 0 deletions test/ipaddress/ipv6_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ def test_method_compressed
assert_equal "1::1", @klass.new("1:0:0:0:0:0:0:1").compressed
end

def test_method_link_local?
assert_equal true, @klass.new("fe80::1").link_local?
assert_equal true, @klass.new("fe80:ffff::1").link_local?
assert_equal false, @klass.new("fe81::1").link_local?
end

def test_method_unspecified?
assert_equal true, @klass.new("::").unspecified?
assert_equal false, @ip.unspecified?
Expand Down

0 comments on commit 580edc4

Please sign in to comment.