Class: Sys::Uname
- Inherits:
-
Object
- Object
- Sys::Uname
- Extended by:
- FFI::Library, Memoist
- Defined in:
- lib/sys/unix/uname.rb,
lib/sys/uname.rb,
lib/sys/windows/uname.rb
Overview
The Uname class encapsulates uname (platform) information.
Defined Under Namespace
Classes: Error, UnameStruct
Constant Summary collapse
- VERSION =
The version of the sys-uname gem.
'1.5.1'
Class Method Summary collapse
-
.architecture(cpu_num = 0, host = Socket.gethostname) ⇒ Object
Returns the CPU architecture, e.g.
-
.dhcp_cache ⇒ Object
The string consisting of the ASCII hexidecimal encoding of the name of the interface configured by boot(1M) followed by the DHCPACK reply from the server.
-
.hw_provider ⇒ Object
The name of the of the hardware provider.
-
.hw_serial ⇒ Object
The ASCII representation of the hardware-specific serial number of the physical machine on which the function is executed.
-
.isa_list ⇒ Object
The variant instruction set architectures executable on the current system.
-
.machine(cpu_num = 0, host = Socket.gethostname) ⇒ Object
Returns the machine hardware type.
-
.model ⇒ Object
Returns the model type.
-
.nodename(host = Socket.gethostname) ⇒ Object
Returns the nodename.
-
.platform ⇒ Object
The specific model of the hardware platform, e.g Sun-Blade-1500, etc.
-
.release(host = Socket.gethostname) ⇒ Object
Returns the release number, e.g.
-
.srpc_domain ⇒ Object
The Secure Remote Procedure Call domain name.
-
.sysname(host = Socket.gethostname) ⇒ Object
Returns the operating system name, e.g.
-
.uname(host = Socket.gethostname) ⇒ Object
Returns a struct of type UnameStruct that contains sysname, nodename, machine, version, and release, as well as a plethora of other fields.
-
.version(host = Socket.gethostname) ⇒ Object
Returns the version plus patch information of the operating system, separated by a hyphen, e.g.
Class Method Details
.architecture(cpu_num = 0, host = Socket.gethostname) ⇒ Object
Returns the CPU architecture, e.g. "x86"
205 206 207 |
# File 'lib/sys/unix/uname.rb', line 205 def self.architecture uname.architecture end |
.dhcp_cache ⇒ Object
The string consisting of the ASCII hexidecimal encoding of the name of the interface configured by boot(1M) followed by the DHCPACK reply from the server.
219 220 221 |
# File 'lib/sys/unix/uname.rb', line 219 def self.dhcp_cache uname.dhcp_cache end |
.hw_provider ⇒ Object
The name of the of the hardware provider.
239 240 241 |
# File 'lib/sys/unix/uname.rb', line 239 def self.hw_provider uname.hw_provider end |
.hw_serial ⇒ Object
The ASCII representation of the hardware-specific serial number of the physical machine on which the function is executed.
233 234 235 |
# File 'lib/sys/unix/uname.rb', line 233 def self.hw_serial uname.hw_serial.to_i end |
.isa_list ⇒ Object
The variant instruction set architectures executable on the current system.
226 227 228 |
# File 'lib/sys/unix/uname.rb', line 226 def self.isa_list uname.isa_list end |
.machine(cpu_num = 0, host = Socket.gethostname) ⇒ Object
Returns the machine hardware type. e.g. "i686".
This may or may not return the expected value because some CPU types were unknown to the OS when the OS was originally released. It appears that MS doesn't necessarily patch this, either.
185 186 187 |
# File 'lib/sys/unix/uname.rb', line 185 def self.machine uname.machine end |
.model ⇒ Object
Returns the model type.
Example:
Uname.model # => 'MacBookPro5,3'
196 197 198 |
# File 'lib/sys/unix/uname.rb', line 196 def self.model uname.model end |
.nodename(host = Socket.gethostname) ⇒ Object
Returns the nodename. This is usually, but not necessarily, the same as the system's hostname.
155 156 157 |
# File 'lib/sys/unix/uname.rb', line 155 def self.nodename uname.nodename end |
.platform ⇒ Object
The specific model of the hardware platform, e.g Sun-Blade-1500, etc.
211 212 213 |
# File 'lib/sys/unix/uname.rb', line 211 def self.platform uname.platform end |
.release(host = Socket.gethostname) ⇒ Object
Returns the release number, e.g. 5.1.2600.
165 166 167 |
# File 'lib/sys/unix/uname.rb', line 165 def self.release uname.release end |
.srpc_domain ⇒ Object
The Secure Remote Procedure Call domain name.
245 246 247 |
# File 'lib/sys/unix/uname.rb', line 245 def self.srpc_domain uname.srpc_domain end |
.sysname(host = Socket.gethostname) ⇒ Object
Returns the operating system name, e.g. "Microsoft Windows XP Home"
143 144 145 |
# File 'lib/sys/unix/uname.rb', line 143 def self.sysname uname.sysname end |
.uname(host = Socket.gethostname) ⇒ Object
Returns a struct of type UnameStruct that contains sysname, nodename, machine, version, and release, as well as a plethora of other fields. Please see the MSDN documentation for what each of these fields mean.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/sys/unix/uname.rb', line 109 def self.uname utsname = UnameFFIStruct.new raise Error, 'uname() function call failed' if uname_c(utsname) < 0 struct = UnameStruct.new struct[:sysname] = utsname[:sysname].to_s struct[:nodename] = utsname[:nodename].to_s struct[:release] = utsname[:release].to_s struct[:version] = utsname[:version].to_s struct[:machine] = utsname[:machine].to_s struct[:model] = get_model() if RbConfig::CONFIG['host_os'] =~ /darwin|bsd|dragonfly/i struct[:id_number] = utsname[:__id_number].to_s if RbConfig::CONFIG['host_os'] =~ /hpux/i struct[:domainname] = utsname[:domainname].to_s if RbConfig::CONFIG['host_os'] =~ /linux/i # Let's add a members method that works for testing and compatibility if struct.members.nil? struct.instance_eval " def members\n @table.keys.map(&:to_s)\n end\n RUBY\n end\n\n struct.freeze\nend\n", __FILE__, __LINE__ + 1 |
.version(host = Socket.gethostname) ⇒ Object
Returns the version plus patch information of the operating system, separated by a hyphen, e.g. "2915-Service Pack 2".
The instance name is unpredictable, so we have to resort to using the 'InstancesOf' method to get the data we need, rather than including it as part of the connection.
175 176 177 |
# File 'lib/sys/unix/uname.rb', line 175 def self.version uname.version end |