Class: Plat4m::System
- Inherits:
-
Object
- Object
- Plat4m::System
- Defined in:
- lib/plat4m/system.rb
Overview
Instances of this class identify a system and provide access to system management support.
Defined Under Namespace
Instance Attribute Summary collapse
-
#os ⇒ Object
readonly
Returns the value of attribute os.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
Instance Method Summary collapse
- #arm? ⇒ Boolean
- #bits ⇒ Object
- #cpu_count ⇒ Object
- #darwin? ⇒ Boolean
- #dev_null ⇒ Object
- #freebsd? ⇒ Boolean
-
#initialize(platform, os) ⇒ System
constructor
A new instance of System.
- #intel? ⇒ Boolean
- #kind ⇒ Object
- #linux? ⇒ Boolean
- #macosx? ⇒ Boolean (also: #osx?)
- #windows? ⇒ Boolean
Constructor Details
#initialize(platform, os) ⇒ System
Returns a new instance of System.
84 85 86 87 88 89 90 |
# File 'lib/plat4m/system.rb', line 84 def initialize(platform, os) unless platform && platform.complete? && os && os.complete? raise "Invalid system specification : #{os} @ #{platform}" end @platform = platform @os = os end |
Instance Attribute Details
#os ⇒ Object (readonly)
Returns the value of attribute os.
92 93 94 |
# File 'lib/plat4m/system.rb', line 92 def os @os end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
92 93 94 |
# File 'lib/plat4m/system.rb', line 92 def platform @platform end |
Instance Method Details
#arm? ⇒ Boolean
102 103 104 |
# File 'lib/plat4m/system.rb', line 102 def arm? @platform.arch =~ /arm/ end |
#bits ⇒ Object
106 107 108 |
# File 'lib/plat4m/system.rb', line 106 def bits @platform.bits end |
#cpu_count ⇒ Object
110 111 112 |
# File 'lib/plat4m/system.rb', line 110 def cpu_count @platform.cpus end |
#darwin? ⇒ Boolean
122 123 124 |
# File 'lib/plat4m/system.rb', line 122 def darwin? @os.id == :darwin end |
#dev_null ⇒ Object
135 136 137 |
# File 'lib/plat4m/system.rb', line 135 def dev_null windows? ? 'NUL' : '/dev/null' end |
#freebsd? ⇒ Boolean
131 132 133 |
# File 'lib/plat4m/system.rb', line 131 def freebsd? @os.id == :freebsd end |
#intel? ⇒ Boolean
98 99 100 |
# File 'lib/plat4m/system.rb', line 98 def intel? @platform.arch =~ /x86/ end |
#kind ⇒ Object
94 95 96 |
# File 'lib/plat4m/system.rb', line 94 def kind "#{@platform.arch}-#{@os.id}" end |
#linux? ⇒ Boolean
114 115 116 |
# File 'lib/plat4m/system.rb', line 114 def linux? @os.id == :linux end |
#macosx? ⇒ Boolean Also known as: osx?
126 127 128 |
# File 'lib/plat4m/system.rb', line 126 def macosx? darwin? && @os.distro == 'MacOSX' end |
#windows? ⇒ Boolean
118 119 120 |
# File 'lib/plat4m/system.rb', line 118 def windows? @os.id == :windows end |