Class: IPAddress::IPv6::Loopback

Inherits:
IPAddress::IPv6 show all
Defined in:
lib/ipaddress/ipv6.rb

Overview

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 IPv6#loopback? method:

ip.loopback?
  #=> true

The IPv6 loopback address corresponds to 127.0.0.1 in IPv4.

Constant Summary

Constants inherited from IPAddress::IPv6

IN6FORMAT, MAX_PREFIX, Prefix, RE

Constants inherited from IPAddress

AUTHORS, GEM, MAX_PREFIX, NAME, VERSION

Instance Method Summary collapse

Methods inherited from IPAddress::IPv6

#[], #address, compress, #compressed, #data, expand, #groups, groups, #hexs, #literal, #loopback?, #mapped?, parse_data, parse_hex, parse_i, #prefix, #reverse, #to_hex, #to_i, #to_s, #to_string_uncompressed, #unspecified?, #version

Methods inherited from IPAddress

#<=>, #at, #bits, #boundaries, #broadcast, #broadcast_i, #distance, #each, #each_host, #each_i, #exact_supernet, #first, #hash, #hosts, #include?, #include_all?, #include_exactly?, #inspect, #ipv4?, #ipv6?, #last, #mapped, #network, #network?, #network_i, #new_prefix, #overlap?, #overlap_i?, parse, parse_i, #proper_supernet, #range, #size, #span, #span_i, #split, #subnet, subtract, #subtract, subtract!, #succ, #summarize, summarize, #supernet, #to_string, valid?, valid_ipv4?, valid_ipv4_netmask?, valid_ipv6?

Methods included from Conversions

#addr2ary, #addr2bits, #ary2addr, #ary2data, #ary2int, #bits2addr, #data2ary, #data2bits, #data2int, #int2addr, #int2ary, #int2data

Constructor Details

#initializeLoopback

Creates a new IPv6 unspecified address

ip = IPAddress::IPv6::Loopback.new

ip.to_string
  #=> "::1/128"


543
544
545
# File 'lib/ipaddress/ipv6.rb', line 543

def initialize
  @groups = Array.new(7, 0) << 1
end