Class: Plat4m::System::OS
- Inherits:
-
Object
- Object
- Plat4m::System::OS
- Defined in:
- lib/plat4m/system.rb
Overview
Provides information about the operating system.
Instance Attribute Summary collapse
-
#distro ⇒ Object
(also: #distribution)
readonly
Returns the value of attribute distro.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#pkgman ⇒ Object
readonly
Returns the value of attribute pkgman.
-
#release ⇒ Object
readonly
Returns the value of attribute release.
Instance Method Summary collapse
- #complete? ⇒ Boolean
- #has_sudo? ⇒ Boolean
-
#initialize(id: nil, distro: nil, variant: nil, release: nil, pkgman: nil, **other) ⇒ OS
constructor
A new instance of OS.
- #is_root? ⇒ Boolean
- #to_s ⇒ Object
- #variant ⇒ Object
Constructor Details
#initialize(id: nil, distro: nil, variant: nil, release: nil, pkgman: nil, **other) ⇒ OS
Returns a new instance of OS.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/plat4m/system.rb', line 38 def initialize(id: nil, distro: nil, variant: nil, release: nil, pkgman: nil, **other) @id = id @distro = distro @variant = variant @release = release @pkgman = pkgman @other = other @other.each_key do |key| unless self.respond_to?(key.to_sym) singleton_class.class_eval <<~__CODE define_method(:#{key}) do @other['#{key}'] end __CODE end end end |
Instance Attribute Details
#distro ⇒ Object (readonly) Also known as: distribution
Returns the value of attribute distro.
56 57 58 |
# File 'lib/plat4m/system.rb', line 56 def distro @distro end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
56 57 58 |
# File 'lib/plat4m/system.rb', line 56 def id @id end |
#pkgman ⇒ Object (readonly)
Returns the value of attribute pkgman.
56 57 58 |
# File 'lib/plat4m/system.rb', line 56 def pkgman @pkgman end |
#release ⇒ Object (readonly)
Returns the value of attribute release.
56 57 58 |
# File 'lib/plat4m/system.rb', line 56 def release @release end |
Instance Method Details
#complete? ⇒ Boolean
64 65 66 67 68 |
# File 'lib/plat4m/system.rb', line 64 def complete? ::Symbol === @id && ::String === @distro && !@distro.empty? ::String === @release && !@release.empty? end |
#has_sudo? ⇒ Boolean
74 75 76 |
# File 'lib/plat4m/system.rb', line 74 def has_sudo? @pkgman ? @pkgman.has_sudo? : false end |
#is_root? ⇒ Boolean
70 71 72 |
# File 'lib/plat4m/system.rb', line 70 def is_root? @pkgman ? @pkgman.is_root? : false end |
#to_s ⇒ Object
78 79 80 |
# File 'lib/plat4m/system.rb', line 78 def to_s "#{@distro}-#{@release}[#{@id}#{@variant ? " #{@variant}" : ''}]" end |
#variant ⇒ Object
58 59 60 |
# File 'lib/plat4m/system.rb', line 58 def variant @variant || @distro end |