class IPAddress::IPAddress::IPAddress::IPv6::Loopback
The loopback address is a unicast localhost address. If an
application in a host sends packets to this address, the IPv6 stack will loop these packets back on the same virtual interface.
Loopback addresses are expressed in the following form:
::1
or, with their appropriate prefix,
::1/128
As for the unspecified addresses, IPv6 loopbacks can be created with IPAddress calling their own class:
ip = IPAddress::IPv6::Loopback.new ip.to_string #=> "::1/128"
or by using the wrapper:
ip = IPAddress "::1" ip.to_string #=> "::1/128"
Checking if an address is loopback is easy with the IPAddress::IPv6#loopback? method:
ip.loopback? #=> true
Public Class Methods
new()
click to toggle source
Creates a new IPv6 unspecified address
ip = IPAddress::IPv6::Loopback.new ip.to_string #=> "::1/128"
# File lib/ipaddress/ipv6.rb, line 754 def initialize @address = ("0000:"*7)+"0001" @groups = Array.new(7,0).push(1) @prefix = Prefix128.new(128) @compressed = compress_address end