Class: Ifconf::Parsers::LinkLayerLine

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

Overview

Frozen value object wrapping the link layer data from an ifconfig block. Searches the block for an ether/loop line and txqueuelen. Exposes the raw encapsulation name, MAC string, and TX queue length.

Constant Summary collapse

%r{\A\s*(ether|loop|link/ether)\b}
ETHER_KEYWORD_PATTERN =
/\bether\b/
ENCAP_PATTERN =
/\(([^)]+)\)/
TXQUEUE_PATTERN =
/txqueuelen\s+(\d+)/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block) ⇒ LinkLayerLine

Returns a new instance of LinkLayerLine.



16
17
18
19
20
21
# File 'lib/ifconf/parsers/link_layer_line.rb', line 16

def initialize(block)
  link_line = block.find_line(LINK_LINE_PATTERN)
  @tx_queue_len = extract_txqueuelen(block)
  extract_link_fields(link_line)
  freeze
end

Instance Attribute Details

#encapsulationObject (readonly)

Returns the value of attribute encapsulation.



14
15
16
# File 'lib/ifconf/parsers/link_layer_line.rb', line 14

def encapsulation
  @encapsulation
end

#macObject (readonly)

Returns the value of attribute mac.



14
15
16
# File 'lib/ifconf/parsers/link_layer_line.rb', line 14

def mac
  @mac
end

#tx_queue_lenObject (readonly)

Returns the value of attribute tx_queue_len.



14
15
16
# File 'lib/ifconf/parsers/link_layer_line.rb', line 14

def tx_queue_len
  @tx_queue_len
end