Class: Freshen::System

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSystem

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_kernelsObject (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

#kernelObject

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

Returns:

  • (Boolean)


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