Class: DIY::DeviceFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/diy/device_finder.rb

Class Method Summary collapse

Class Method Details

.devicesObject



21
22
23
# File 'lib/diy/device_finder.rb', line 21

def devices
  FFI::PCap.dump_devices
end

.pp_devicesObject



15
16
17
18
19
# File 'lib/diy/device_finder.rb', line 15

def pp_devices
  devices.each do |device, net|
    printf "%20s\t:\t%s\n", device, net
  end
end

.smart_selectObject



4
5
6
7
8
9
10
11
12
13
# File 'lib/diy/device_finder.rb', line 4

def smart_select
  ret = devices.find do |device, net|
    !device.match(/dialup/) && net != nil && net != "0.0.0.0/0.0.0.0"
  end
  if ret
    ret[0]
  else
    devices[0]
  end
end