module Env::Variables
Public Instance Methods
The default browser to use.
@return [String, nil]
The name of the browser program.
# File lib/env/variables.rb, line 182 def browser env['BROWSER'] end
The number of columns in the terminal.
@return [Integer]
The number of columns.
# File lib/env/variables.rb, line 122 def columns env['COLUMNS'].to_i if env['COLUMNS'] end
Determines whether optional Debugging was enabled.
@return [Boolean]
Specifies whether the `DEBUG` variable was specified.
@since 0.2.0
# File lib/env/variables.rb, line 194 def debug? true if env['DEBUG'] end
The default editor to use.
@return [String, nil]
The name of the editor program.
# File lib/env/variables.rb, line 172 def editor env['EDITOR'] end
The environment variables.
@return [Hash{String => String}]
The Hash of environment variable names and values.
@api semipublic
# File lib/env/variables.rb, line 13 def env ENV end
The home directory.
@return [Pathname]
The path of the home directory.
# File lib/env/variables.rb, line 69 def home # logic adapted from Gem.find_home. path = if (env['HOME'] || env['USERPROFILE']) env['HOME'] || env['USERPROFILE'] elsif (env['HOMEDRIVE'] && env['HOMEPATH']) "#{env['HOMEDRIVE']}#{env['HOMEPATH']}" else begin File.expand_path('~') rescue if File::ALT_SEPARATOR 'C:/' else '/' end end end return Pathname.new(path) end
The host-name of the system.
@return [String]
The host-name.
@since 0.3.0
# File lib/env/variables.rb, line 45 def host_name env['HOSTNAME'] end
The default language.
@return [Array<String, String>]
The language name and encoding.
# File lib/env/variables.rb, line 96 def lang if (lang = env['LANG']) lang.split('.',2) else [] end end
The directories to search within for libraries.
@return [Array<Pathname>]
The paths of the directories.
# File lib/env/variables.rb, line 33 def ld_library_paths parse_paths(env['LD_LIBRARY_PATH']) end
The number of lines in the terminal.
@return [Integer]
The number of lines.
# File lib/env/variables.rb, line 132 def lines env['LINES'].to_i if env['LINES'] end
The directories to search within for executables.
@return [Array<Pathname>]
The paths of the directories.
# File lib/env/variables.rb, line 23 def paths parse_paths(env['PATH']) end
The path of the default shell.
@return [String, nil]
The path to the default shell.
# File lib/env/variables.rb, line 142 def shell env['SHELL'] end
The name of the default shell.
@return [String, nil]
The program name of the shell.
# File lib/env/variables.rb, line 152 def shell_name File.basename(shell) if shell end
The default terminal to use.
@return [String, nil]
The name of the terminal program.
# File lib/env/variables.rb, line 162 def terminal env['COLORTERM'] || env['TERM'] end
The default timezone.
@return [String, nil]
The timezone name.
@since 0.2.0
# File lib/env/variables.rb, line 112 def timezone env['TZ'] end
The name of the current user.
@return [String]
The name of the user.
@since 0.3.0
# File lib/env/variables.rb, line 57 def user # USER is used on GNU/Linux and Windows # LOGNAME is the POSIX user-name ENV variable env['USER'] || env['LOGNAME'] end
Protected Instance Methods
Parses a String containing multiple paths.
@return [Array<Pathname>]
The multiple paths.
# File lib/env/variables.rb, line 206 def parse_paths(paths) if paths paths.split(File::PATH_SEPARATOR).map do |path| Pathname.new(path) end else [] end end