Class: Ifconf::Parsers::HeaderLine

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

Overview

Frozen value object wrapping the first line of an ifconfig block. Extracts the interface name, flags bitmask, flag names, and MTU.

Constant Summary collapse

FLAGS_PATTERN =
/flags=(\d+)<([^>]*)>/
MTU_PATTERN =
/\bmtu\s+(\d+)/
NAME_PATTERN =
/\A(.+?):\s*flags=/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line) ⇒ HeaderLine

Returns a new instance of HeaderLine.



12
13
14
15
16
17
18
# File 'lib/ifconf/parsers/header_line.rb', line 12

def initialize(line)
  @name = extract_name(line)
  @flags_int = extract_flags_int(line)
  @flag_names = extract_flag_names(line)
  @mtu = extract_mtu(line)
  freeze
end

Instance Attribute Details

#flag_namesObject (readonly)

Returns the value of attribute flag_names.



10
11
12
# File 'lib/ifconf/parsers/header_line.rb', line 10

def flag_names
  @flag_names
end

#flags_intObject (readonly)

Returns the value of attribute flags_int.



10
11
12
# File 'lib/ifconf/parsers/header_line.rb', line 10

def flags_int
  @flags_int
end

#mtuObject (readonly)

Returns the value of attribute mtu.



10
11
12
# File 'lib/ifconf/parsers/header_line.rb', line 10

def mtu
  @mtu
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/ifconf/parsers/header_line.rb', line 10

def name
  @name
end