Module: Env::Variables
- Included in:
- Env
- Defined in:
- lib/env/variables.rb
Instance Method Summary collapse
-
#browser ⇒ String?
The default browser to use.
-
#columns ⇒ Integer
The number of columns in the terminal.
-
#debug? ⇒ Boolean
Determines whether optional Debugging was enabled.
-
#editor ⇒ String?
The default editor to use.
-
#env_hash ⇒ Hash{String => String}
The environment variables.
-
#home ⇒ Pathname
The home directory.
-
#lang ⇒ Array<String, String>
The default language.
-
#ld_library_paths ⇒ Array<Pathname>
The directories to search within for libraries.
-
#lines ⇒ Integer
The number of lines in the terminal.
-
#parse_paths(paths) ⇒ Array<Pathname>
protected
Parses a String containing multiple paths.
-
#paths ⇒ Array<Pathname>
The directories to search within for executables.
-
#shell ⇒ String?
The path of the default shell.
-
#shell_name ⇒ String?
The name of the default shell.
-
#terminal ⇒ String?
The default terminal to use.
-
#timezone ⇒ String?
The default timezone.
Instance Method Details
#browser ⇒ String?
The default browser to use.
154 155 156 |
# File 'lib/env/variables.rb', line 154 def browser env_hash['BROWSER'] end |
#columns ⇒ Integer
The number of columns in the terminal.
94 95 96 |
# File 'lib/env/variables.rb', line 94 def columns env_hash['COLUMNS'].to_i if env_hash['COLUMNS'] end |
#debug? ⇒ Boolean
Determines whether optional Debugging was enabled.
166 167 168 |
# File 'lib/env/variables.rb', line 166 def debug? true if env_hash['DEBUG'] end |
#editor ⇒ String?
The default editor to use.
144 145 146 |
# File 'lib/env/variables.rb', line 144 def editor env_hash['EDITOR'] end |
#env_hash ⇒ Hash{String => String}
The environment variables.
11 12 13 |
# File 'lib/env/variables.rb', line 11 def env_hash ENV end |
#home ⇒ Pathname
The home directory.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/env/variables.rb', line 41 def home # logic adapted from Gem.find_home. path = if (env_hash['HOME'] || env_hash['USERPROFILE']) env_hash['HOME'] || env_hash['USERPROFILE'] elsif (env_hash['HOMEDRIVE'] && env_hash['HOMEPATH']) "#{env_hash['HOMEDRIVE']}#{env_hash['HOMEPATH']}" else begin File.('~') rescue if File::ALT_SEPARATOR 'C:/' else '/' end end end return Pathname.new(path) end |
#lang ⇒ Array<String, String>
The default language.
68 69 70 71 72 73 74 |
# File 'lib/env/variables.rb', line 68 def lang if (lang = env_hash['LANG']) lang.split('.',2) else [] end end |
#ld_library_paths ⇒ Array<Pathname>
The directories to search within for libraries.
31 32 33 |
# File 'lib/env/variables.rb', line 31 def ld_library_paths parse_paths(env_hash['LD_LIBRARY_PATH']) end |
#lines ⇒ Integer
The number of lines in the terminal.
104 105 106 |
# File 'lib/env/variables.rb', line 104 def lines env_hash['LINES'].to_i if env_hash['LINES'] end |
#parse_paths(paths) ⇒ Array<Pathname> (protected)
Parses a String containing multiple paths.
178 179 180 181 182 183 184 185 186 |
# File 'lib/env/variables.rb', line 178 def parse_paths(paths) if paths paths.split(File::PATH_SEPARATOR).map do |path| Pathname.new(path) end else [] end end |
#paths ⇒ Array<Pathname>
The directories to search within for executables.
21 22 23 |
# File 'lib/env/variables.rb', line 21 def paths parse_paths(env_hash['PATH']) end |
#shell ⇒ String?
The path of the default shell.
114 115 116 |
# File 'lib/env/variables.rb', line 114 def shell env_hash['SHELL'] end |
#shell_name ⇒ String?
The name of the default shell.
124 125 126 |
# File 'lib/env/variables.rb', line 124 def shell_name File.basename(shell) if shell end |
#terminal ⇒ String?
The default terminal to use.
134 135 136 |
# File 'lib/env/variables.rb', line 134 def terminal env_hash['COLORTERM'] || env_hash['TERM'] end |
#timezone ⇒ String?
The default timezone.
84 85 86 |
# File 'lib/env/variables.rb', line 84 def timezone env['TZ'] end |