Module: HostOS::Support
- Included in:
- HostOS
- Defined in:
- lib/host-os/support.rb
Overview
You need to require host-os/support explicitly.
This module provides helpful support methods for the HostOS module.
It adds attributes and methods depending on the detected operating system and Ruby interpreter.
Instance Attribute Summary collapse
-
#dev_null ⇒ String
readonly
Name of or path to the null device.
-
#open_command ⇒ String
readonly
Name of the open command.
-
#rss_bytes ⇒ Integer
readonly
Number of bytes used by the current process.
-
#suggested_thread_count ⇒ Integer
readonly
Suggested number of threads to use.
-
#temp_dir ⇒ String
readonly
Name of the temporary directory.
Instance Method Summary collapse
-
#app_config_path(app_name) ⇒ String
Determines the name of the directory where application specific data should be stored.
Instance Attribute Details
#dev_null ⇒ String (readonly)
This attribute is only available on Windows, OS2 and Unix systems for older Ruby versions.
Returns name of or path to the null device.
18 |
# File 'lib/host-os/support.rb', line 18 def dev_null = File::NULL |
#open_command ⇒ String (readonly)
This attribute is only available on Windows, MacOS and Linux systems.
Returns name of the open command.
31 |
# File 'lib/host-os/support.rb', line 31 def open_command = 'start' |
#rss_bytes ⇒ Integer (readonly)
This attribute is only available on Windows and Unix or when using JRuby
Returns number of bytes used by the current process.
43 44 45 46 47 48 |
# File 'lib/host-os/support.rb', line 43 def rss_bytes `tasklist /FI "PID eq #{Process.pid}" /FO CSV`.split(',"')[-1].tr( ',.', '__' ).to_i * 1024 end |
#suggested_thread_count ⇒ Integer (readonly)
Returns suggested number of threads to use.
87 88 89 |
# File 'lib/host-os/support.rb', line 87 def suggested_thread_count @suggested_thread_count ||= find_suggested_thread_count end |
#temp_dir ⇒ String (readonly)
Returns name of the temporary directory.
93 |
# File 'lib/host-os/support.rb', line 93 def temp_dir = (@temp_dir ||= find_temp_dir) |
Instance Method Details
#app_config_path(app_name) ⇒ String
This method is only available on Windows and Posix-compatible systems.
Determines the name of the directory where application specific data should be stored.
68 69 70 71 72 73 74 |
# File 'lib/host-os/support.rb', line 68 def app_config_path(app_name) File.( app_name, ENV['LOCALAPPDATA'] || "#{ENV['USERPROFILE']}/Local Settings/Application Data" ) end |