Class: Ifconf::LinkLayer
- Inherits:
-
Object
- Object
- Ifconf::LinkLayer
- Defined in:
- lib/ifconf/link_layer.rb
Overview
Base class for link-layer types, holding encapsulation kind, hardware address, and TX queue length.
Direct Known Subclasses
EthernetLinkLayer, LoopbackLinkLayer, PppLinkLayer, TunnelLinkLayer, UnknownLinkLayer
Instance Attribute Summary collapse
-
#encapsulation ⇒ Object
readonly
Returns the value of attribute encapsulation.
-
#hardware_addr ⇒ Object
readonly
Returns the value of attribute hardware_addr.
-
#tx_queue_len ⇒ Object
readonly
Returns the value of attribute tx_queue_len.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(encapsulation:, hardware_addr:, tx_queue_len:) ⇒ LinkLayer
constructor
A new instance of LinkLayer.
- #to_s ⇒ Object
Constructor Details
#initialize(encapsulation:, hardware_addr:, tx_queue_len:) ⇒ LinkLayer
Returns a new instance of LinkLayer.
17 18 19 20 21 22 |
# File 'lib/ifconf/link_layer.rb', line 17 def initialize(encapsulation:, hardware_addr:, tx_queue_len:) @encapsulation = encapsulation @hardware_addr = hardware_addr @tx_queue_len = tx_queue_len freeze end |
Instance Attribute Details
#encapsulation ⇒ Object (readonly)
Returns the value of attribute encapsulation.
4 5 6 |
# File 'lib/ifconf/link_layer.rb', line 4 def encapsulation @encapsulation end |
#hardware_addr ⇒ Object (readonly)
Returns the value of attribute hardware_addr.
4 5 6 |
# File 'lib/ifconf/link_layer.rb', line 4 def hardware_addr @hardware_addr end |
#tx_queue_len ⇒ Object (readonly)
Returns the value of attribute tx_queue_len.
4 5 6 |
# File 'lib/ifconf/link_layer.rb', line 4 def tx_queue_len @tx_queue_len end |
Class Method Details
.build(encap_string, hardware_addr, tx_queue_len) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/ifconf/link_layer.rb', line 6 def self.build(encap_string, hardware_addr, tx_queue_len) klass = case encap_string when "Ethernet" then EthernetLinkLayer when "Local Loopback" then LoopbackLinkLayer when "IPIP Tunnel", "IPv6-in-IPv4" then TunnelLinkLayer when "Point-to-Point Protocol", "Point-to-Point" then PppLinkLayer else UnknownLinkLayer end klass.new(hardware_addr: hardware_addr, tx_queue_len: tx_queue_len) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
26 27 28 29 30 31 |
# File 'lib/ifconf/link_layer.rb', line 26 def ==(other) other.is_a?(LinkLayer) && @encapsulation == other.encapsulation && @hardware_addr == other.hardware_addr && @tx_queue_len == other.tx_queue_len end |
#hash ⇒ Object
35 |
# File 'lib/ifconf/link_layer.rb', line 35 def hash = [@encapsulation, @hardware_addr, @tx_queue_len].hash |
#to_s ⇒ Object
24 |
# File 'lib/ifconf/link_layer.rb', line 24 def to_s = @encapsulation.to_s |