Class: Freshen::System
- Inherits:
-
Object
- Object
- Freshen::System
- Defined in:
- lib/freshen/system.rb
Overview
The system class responsible for checking if the current system’s kernel is supported.
Instance Attribute Summary collapse
-
#supported_kernels ⇒ Object
readonly
An array of supported kernels.
Class Method Summary collapse
-
.check_supported! ⇒ Object
Check if the current Operating System is supported and if not, raise an UnsupportedOperatingSystem error.
Instance Method Summary collapse
-
#check_supported! ⇒ Object
Check if the current kernel is supported and if not, raise an UnsupportedKernel error.
-
#initialize ⇒ System
constructor
Setup an instance of this class with an array of supported kernels.
-
#kernel ⇒ Object
Get the current version of this system’s kernel.
-
#supported? ⇒ Boolean
A boolean value of whether or not this system’s kernel is supported.
Constructor Details
#initialize ⇒ System
Setup an instance of this class with an array of supported kernels
Example:
>> Freshen::System.new
=> #<Freshen:0x00000000000000>
21 22 23 |
# File 'lib/freshen/system.rb', line 21 def initialize @supported_kernels = [:darwin, :linux] end |
Instance Attribute Details
#supported_kernels ⇒ Object (readonly)
An array of supported kernels
12 13 14 |
# File 'lib/freshen/system.rb', line 12 def supported_kernels @supported_kernels end |
Class Method Details
.check_supported! ⇒ Object
Check if the current Operating System is supported and if not, raise an UnsupportedOperatingSystem error
Example:
>> Freshen::System.check_supported!
=> nil
78 79 80 81 |
# File 'lib/freshen/system.rb', line 78 def self.check_supported! system = Freshen::System.new system.check_supported! end |
Instance Method Details
#check_supported! ⇒ Object
Check if the current kernel is supported and if not, raise an UnsupportedKernel error
Example:
>> system = Freshen::System.new
>> system.check_supported!
=> nil
65 66 67 68 69 |
# File 'lib/freshen/system.rb', line 65 def check_supported! unless supported? raise UnsupportedKernel.new(current) end end |
#kernel ⇒ Object
Get the current version of this system’s kernel
Example (OS X):
>> system = Freshen::System.new
>> system.kernel
=> darwin
Example (Linux):
>> system = Freshen::System.new
>> system.kernel
=> linux
37 38 39 |
# File 'lib/freshen/system.rb', line 37 def kernel Gem::Platform.local.os end |
#supported? ⇒ Boolean
A boolean value of whether or not this system’s kernel is supported
Example:
>> system = Freshen::System.new
>> system.supported?
=> true
49 50 51 52 53 54 55 |
# File 'lib/freshen/system.rb', line 49 def supported? @supported_kernels.each do |k| return true if k.to_s == kernel end return false end |