class Ifconfig
Detects your current IP via `ifconfig`
Public Class Methods
new(network_interface, _version)
click to toggle source
# File lib/detectors/ifconfig.rb, line 5 def initialize(network_interface, _version) @network_interface = network_interface end
Public Instance Methods
detect()
click to toggle source
# File lib/detectors/ifconfig.rb, line 9 def detect command = [ "ifconfig #{@network_interface} inet6", 'grep inet6', 'grep -v fe80', 'grep -v deprecated' ].join(' | ') raw = `#{command}` ip = raw.lstrip.split(' ')[1] raise 'no ip detected' unless ip ip end