Module: EnvExt::Methods
- Defined in:
- lib/env_ext/methods.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.
-
#home ⇒ Pathname
The home directory.
-
#host_name ⇒ String
The host-name of the system.
-
#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.
-
#term ⇒ String?
(also: #terminal)
The default terminal to use.
-
#timezone ⇒ String?
The default timezone.
-
#user ⇒ String
The name of the current user.
Instance Method Details
#browser ⇒ String?
The default browser to use.
166 167 168 |
# File 'lib/env_ext/methods.rb', line 166 def browser self['BROWSER'] end |
#columns ⇒ Integer
The number of columns in the terminal.
104 105 106 |
# File 'lib/env_ext/methods.rb', line 104 def columns self['COLUMNS'].to_i if self['COLUMNS'] end |
#debug? ⇒ Boolean
Determines whether optional Debugging was enabled.
176 177 178 |
# File 'lib/env_ext/methods.rb', line 176 def debug? true if self['DEBUG'] end |
#editor ⇒ String?
The default editor to use.
156 157 158 |
# File 'lib/env_ext/methods.rb', line 156 def editor self['EDITOR'] end |
#home ⇒ Pathname
The home directory.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/env_ext/methods.rb', line 53 def home # logic adapted from Gem.find_home. path = if (self['HOME'] || self['USERPROFILE']) self['HOME'] || self['USERPROFILE'] elsif (self['HOMEDRIVE'] && self['HOMEPATH']) "#{self['HOMEDRIVE']}#{self['HOMEPATH']}" else begin File.('~') rescue if File::ALT_SEPARATOR 'C:/' else '/' end end end return Pathname.new(path) end |
#host_name ⇒ String
The host-name of the system.
31 32 33 |
# File 'lib/env_ext/methods.rb', line 31 def host_name self['HOSTNAME'] end |
#lang ⇒ Array<String, String>
The default language.
80 81 82 83 84 85 86 |
# File 'lib/env_ext/methods.rb', line 80 def lang if (lang = self['LANG']) lang.split('.',2) else [] end end |
#ld_library_paths ⇒ Array<Pathname>
The directories to search within for libraries.
21 22 23 |
# File 'lib/env_ext/methods.rb', line 21 def ld_library_paths parse_paths(self['LD_LIBRARY_PATH']) end |
#lines ⇒ Integer
The number of lines in the terminal.
114 115 116 |
# File 'lib/env_ext/methods.rb', line 114 def lines self['LINES'].to_i if self['LINES'] end |
#parse_paths(paths) ⇒ Array<Pathname> (protected)
Parses a String containing multiple paths.
188 189 190 191 192 193 194 195 196 |
# File 'lib/env_ext/methods.rb', line 188 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.
11 12 13 |
# File 'lib/env_ext/methods.rb', line 11 def paths parse_paths(self['PATH']) end |
#shell ⇒ String?
The path of the default shell.
124 125 126 |
# File 'lib/env_ext/methods.rb', line 124 def shell self['SHELL'] end |
#shell_name ⇒ String?
The name of the default shell.
134 135 136 |
# File 'lib/env_ext/methods.rb', line 134 def shell_name File.basename(shell) if shell end |
#term ⇒ String? Also known as: terminal
The default terminal to use.
144 145 146 |
# File 'lib/env_ext/methods.rb', line 144 def term self['COLORTERM'] || self['TERM'] end |
#timezone ⇒ String?
The default timezone.
94 95 96 |
# File 'lib/env_ext/methods.rb', line 94 def timezone self['TZ'] end |
#user ⇒ String
The name of the current user.
41 42 43 44 45 |
# File 'lib/env_ext/methods.rb', line 41 def user # USER is used on GNU/Linux and Windows # LOGNAME is the POSIX user-name ENV variable self['USER'] || self['LOGNAME'] end |