Class: Cfruby::OS::OSFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/libcfruby/os.rb

Overview

OSFactory implements the Factory pattern and uses a set of heuristics to return an appropriate class of the OS interface

Instance Method Summary collapse

Instance Method Details

#get_osObject

Uses a set of heuristics to determine the OS it is running under and attempts to return an object implementing the OS interface that matches that OS



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/libcfruby/os.rb', line 46

def get_os()
	Cfruby.controller.inform('debug', 'Retrieving an OS object')
	
	# try to use uname to get the OS
	os = set_with_uname()
	if(os != nil)
		Cfruby.controller.inform('debug', "OS #{os['name']}")
		return(os)
	end
	
	# if we failed, try RUBY_PLATFORM
	os = set_with_RUBY_PLATFORM()
	if(os != nil)
		Cfruby.controller.inform('verbose', "OS #{os['name']}")
		return(os)
	end
	
	raise(OSUndetectableError, "OS is not recognized!")
end