Class: EthernetAdapter
- Inherits:
-
NetworkAdapter
- Object
- NetworkAdapter
- EthernetAdapter
- Defined in:
- lib/ifconfig/common/interface_types.rb,
lib/ifconfig/bsd/interface_types.rb,
lib/ifconfig/linux/interface_types.rb,
lib/ifconfig/sunos/interface_types.rb
Overview
each platform defines it’s own set_mac function to get the mac address
Instance Attribute Summary collapse
-
#interrupt ⇒ Object
readonly
Returns the value of attribute interrupt.
-
#mac ⇒ Object
readonly
Returns the value of attribute mac.
-
#rxbytes ⇒ Object
readonly
Returns the value of attribute rxbytes.
-
#rxpackets ⇒ Object
readonly
Returns the value of attribute rxpackets.
-
#txbytes ⇒ Object
readonly
Returns the value of attribute txbytes.
-
#txpackets ⇒ Object
readonly
Returns the value of attribute txpackets.
Attributes inherited from NetworkAdapter
#flags, #mtu, #name, #rx, #status, #tx
Instance Method Summary collapse
-
#initialize(name, ifconfigtxt) ⇒ EthernetAdapter
constructor
A new instance of EthernetAdapter.
- #set_mac ⇒ Object
- #to_s ⇒ Object
Methods inherited from NetworkAdapter
#add_network, #addr_types, #addresses, #addrs_with_type, #array_to_hash_elem, #has_addr?, #ifacetype, #parse_activity, #parse_flags, #parse_ifconfig, #up?
Constructor Details
#initialize(name, ifconfigtxt) ⇒ EthernetAdapter
Returns a new instance of EthernetAdapter.
106 107 108 109 |
# File 'lib/ifconfig/common/interface_types.rb', line 106 def initialize(name,ifconfigtxt) super(name,ifconfigtxt) @mac = set_mac end |
Instance Attribute Details
#interrupt ⇒ Object (readonly)
Returns the value of attribute interrupt.
111 112 113 |
# File 'lib/ifconfig/common/interface_types.rb', line 111 def interrupt @interrupt end |
#mac ⇒ Object (readonly)
Returns the value of attribute mac.
111 112 113 |
# File 'lib/ifconfig/common/interface_types.rb', line 111 def mac @mac end |
#rxbytes ⇒ Object (readonly)
Returns the value of attribute rxbytes.
111 112 113 |
# File 'lib/ifconfig/common/interface_types.rb', line 111 def rxbytes @rxbytes end |
#rxpackets ⇒ Object (readonly)
Returns the value of attribute rxpackets.
111 112 113 |
# File 'lib/ifconfig/common/interface_types.rb', line 111 def rxpackets @rxpackets end |
#txbytes ⇒ Object (readonly)
Returns the value of attribute txbytes.
111 112 113 |
# File 'lib/ifconfig/common/interface_types.rb', line 111 def txbytes @txbytes end |
#txpackets ⇒ Object (readonly)
Returns the value of attribute txpackets.
111 112 113 |
# File 'lib/ifconfig/common/interface_types.rb', line 111 def txpackets @txpackets end |
Instance Method Details
#set_mac ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ifconfig/bsd/interface_types.rb', line 58 def set_mac begin match=@ifconfig.match(/\s+ether\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5})/im) return match[1] unless match.nil? # Openbsd match = @ifconfig.match(/\s+address\:\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5})/im) return match[1] unless match.nil? rescue NoMethodError puts "Couldn't Parse MAC Address for: "+@name end end |
#to_s ⇒ Object
114 115 116 |
# File 'lib/ifconfig/common/interface_types.rb', line 114 def to_s super + "\n MAC: #{@mac}" end |