class MacOS::HardwarePort
Attributes
device[RW]
ethernet_address[RW]
hardware_port[RW]
Public Class Methods
find_by_interface(interface)
click to toggle source
# File lib/MacOS/HardwarePort.rb, line 55 def find_by_interface(interface) all.detect{|hardware_port| hardware_port.interface == interface} end
Also aliased as: find_by_device
find_by_mac_address(mac_address)
click to toggle source
# File lib/MacOS/HardwarePort.rb, line 65 def find_by_mac_address(mac_address) all.detect{|hardware_port| hardware_port.ethernet_address == mac_address} end
Also aliased as: find_by_ethernet_address
find_by_name(name)
click to toggle source
# File lib/MacOS/HardwarePort.rb, line 60 def find_by_name(name) all.detect{|hardware_port| hardware_port.name == name} end
Also aliased as: find_by_hardware_port
new(hardware_port: nil, device: nil, ethernet_address: nil)
click to toggle source
# File lib/MacOS/HardwarePort.rb, line 82 def initialize(hardware_port: nil, device: nil, ethernet_address: nil) @hardware_port = hardware_port @device = device @ethernet_address = ethernet_address end
parse(output = nil)
click to toggle source
# File lib/MacOS/HardwarePort.rb, line 31 def parse(output = nil) output ||= self.output hardware_ports = [] hardware_port = nil output.each_line do |line| # p line if line == "\n" || line == "" hardware_ports << hardware_port if hardware_port hardware_port = new else label, value = line.captures(/^(.+): (.+)/) case label when 'Hardware Port'; hardware_port.hardware_port = value when 'Device'; hardware_port.device = value when 'Ethernet Address'; hardware_port.ethernet_address = value end end end hardware_ports end
Private Class Methods
output()
click to toggle source
# File lib/MacOS/HardwarePort.rb, line 72 def output `networksetup -listallhardwareports` end
Public Instance Methods
interface()
click to toggle source
# File lib/MacOS/HardwarePort.rb, line 96 def interface @device end
mac_address()
click to toggle source
# File lib/MacOS/HardwarePort.rb, line 92 def mac_address @ethernet_address end
name()
click to toggle source
# File lib/MacOS/HardwarePort.rb, line 88 def name @hardware_port end