Class: Cfruby::OS::OS
- Inherits:
-
Object
- Object
- Cfruby::OS::OS
- Defined in:
- lib/libcfruby/os.rb
Overview
The OS class serves only as an in-code description of the OS interface. It can be subclassed, but the methods do nothing useful
Instance Method Summary collapse
-
#[](key) ⇒ Object
An alternative to calling lookup.
-
#get_package_manager ⇒ Object
Returns an object implementing the PackageManager interface as appropriate for the default package management system for a given OS.
-
#get_process_manager ⇒ Object
Returns an object implementing the ProcessManager interface as appropriate for a given OS.
-
#get_scheduler ⇒ Object
Returns an object implementing the Scheduler interface as appropriate for a given OS.
-
#get_user_manager ⇒ Object
Returns an object implementing the UserManager interface as appropriate for a given OS.
-
#lookup(key) ⇒ Object
Returns the value of the given key for this OS.
-
#method_missing(symbol, *args) ⇒ Object
Call lookup on anything we have no real method for.
-
#to_s ⇒ Object
Returns the name-version of the OS.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args) ⇒ Object
Call lookup on anything we have no real method for
164 165 166 167 168 169 170 |
# File 'lib/libcfruby/os.rb', line 164 def method_missing(symbol, *args) if(args == nil or args.length == 0) return lookup(symbol.id2name) end super.method(symbol).call(args) end |
Instance Method Details
#[](key) ⇒ Object
An alternative to calling lookup
158 159 160 |
# File 'lib/libcfruby/os.rb', line 158 def [](key) return(lookup(key)) end |
#get_package_manager ⇒ Object
Returns an object implementing the PackageManager interface as appropriate for the default package management system for a given OS
118 119 120 |
# File 'lib/libcfruby/os.rb', line 118 def get_package_manager() return(Packages::PackageManager.new()) end |
#get_process_manager ⇒ Object
Returns an object implementing the ProcessManager interface as appropriate for a given OS
132 133 134 |
# File 'lib/libcfruby/os.rb', line 132 def get_process_manager() return(Processes::ProcessManager.new()) end |
#get_scheduler ⇒ Object
Returns an object implementing the Scheduler interface as appropriate for a given OS
139 140 141 |
# File 'lib/libcfruby/os.rb', line 139 def get_scheduler() return(Scheduler::Scheduler.new()) end |
#get_user_manager ⇒ Object
Returns an object implementing the UserManager interface as appropriate for a given OS
125 126 127 |
# File 'lib/libcfruby/os.rb', line 125 def get_user_manager() return(Users::UserManager.new()) end |
#lookup(key) ⇒ Object
Returns the value of the given key for this OS. At a minimum an OS should provide the following:
name
-
returns the name of the OS
version
-
the version of the OS
osname
-
e.g. freebsd, linux, windows, etc - these should return true and be case insensitive to allow
lookups of the form lookup(‘Windows’)
hostname
-
the hostname of the machine
In addition to the above name and version should be implemented as get methods for convenience
152 153 154 |
# File 'lib/libcfruby/os.rb', line 152 def lookup(key) return(nil) end |
#to_s ⇒ Object
Returns the name-version of the OS
174 175 176 |
# File 'lib/libcfruby/os.rb', line 174 def to_s() return("#{lookup('name')} #{lookup('version')}") end |