Class: Ifconf::Parsers::Ipv6Line

Inherits:
Object
  • Object
show all
Defined in:
lib/ifconf/parsers/ipv6_line.rb

Overview

Frozen value object wrapping a single inet6 line from an ifconfig block. Extracts the IPv6 address (zone ID stripped), prefix length, and scope_id.

Constant Summary collapse

INET6_PATTERN =
/\binet6\b/
INET6_ADDRESS_PATTERN =
/\binet6\s+(\S+)/
SCOPE_PATTERN =
/scopeid\s+0x[0-9a-f]+<(\w+)>/i
PREFIXLEN_PATTERN =
/\bprefixlen\s+(\d+)/
KNOWN_SCOPES =
Set[:link, :global, :host].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line) ⇒ Ipv6Line

Returns a new instance of Ipv6Line.



14
15
16
17
18
19
# File 'lib/ifconf/parsers/ipv6_line.rb', line 14

def initialize(line)
  @address = extract_address(line)
  @prefix_length = extract_prefix_length(line)
  @scope_id = extract_scope_id(line)
  freeze
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



12
13
14
# File 'lib/ifconf/parsers/ipv6_line.rb', line 12

def address
  @address
end

#prefix_lengthObject (readonly)

Returns the value of attribute prefix_length.



12
13
14
# File 'lib/ifconf/parsers/ipv6_line.rb', line 12

def prefix_length
  @prefix_length
end

#scope_idObject (readonly)

Returns the value of attribute scope_id.



12
13
14
# File 'lib/ifconf/parsers/ipv6_line.rb', line 12

def scope_id
  @scope_id
end