Class: IfconfigWrapper

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ifconfig.rb

Constant Summary collapse

NAME =
'Ruby/Ifconfig'

Instance Method Summary collapse

Constructor Details

#initialize(platform = nil, input = nil, netstat = nil) ⇒ IfconfigWrapper

Can manually specify the platform (should be output of the ‘uname’ command) and the ifconfig input



46
47
48
49
50
# File 'lib/ifconfig.rb', line 46

def initialize(platform=nil,input=nil,netstat=nil)
  platform = self.get_os unless !platform.nil?
  require "ifconfig/"+platform.downcase+"/ifconfig"
  @cfg = Ifconfig.new(input,netstat)
end

Instance Method Details

#get_osObject

Find out what os we are on



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/ifconfig.rb', line 56

def get_os
  plat = IO.popen('uname'){ |f| f.gets.strip }
  case plat
    when 'Windows'
      return plat
    when 'Linux'
      return plat
    when 'SunOS'
      return plat
    when 'FreeBSD','OpenBSD','NetBSD','DragonFly','Darwin'
      return 'BSD'
    else
      return 'Linux'
  end
end

#parseObject



51
52
53
# File 'lib/ifconfig.rb', line 51

def parse
  return @cfg
end