ENV

Class

ENV is a hash-like accessor for environment variables.

Class Methods

Retrieves the value for environment variable name as a String. Returns nil if the named variable does not exist.

Sets the environment variable name to value. If the value given is nil the environment variable is deleted. name must be a string.

Returns an Array of the name and value of the environment variable with name or nil if the name cannot be found.

Removes every environment variable.

Deletes the environment variable with name and returns the value of the variable. If a block is given it will be called when the named environment does not exist.

Deletes every environment variable for which the block evaluates to true.

If no block is given an enumerator is returned instead.

Yields each environment variable name and value.

If no block is given an Enumerator is returned.

Yields each environment variable name.

An Enumerator is returned if no block is given.

Yields each environment variable name and value.

If no block is given an Enumerator is returned.

Yields each environment variable value.

An Enumerator is returned if no block was given.

Returns true when there are no environment variables

Retrieves the environment variable name.

If the given name does not exist and neither default nor a block a provided an KeyError is raised. If a block is given it is called with the missing name to provide a value. If a default value is given it will be returned when no block is given.

Returns true if there is an environment variable with the given name.

Returns true if there is an environment variable with the given value.

Returns true if there is an environment variable with the given name.

Deprecated method that is equivalent to ENV.key

Returns the contents of the environment as a String.

Returns a new hash created by using environment variable names as values and values as names.

Deletes every environment variable where the block evaluates to false.

Returns an enumerator if no block was given.

Returns the name of the environment variable with value. If the value is not found nil is returned.

Returns true if there is an environment variable with the given name.

Returns every environment variable name in an Array

Returns the number of environment variables.

Returns true if there is an environment variable with the given name.

Returns an Array of the name and value of the environment variable with value or nil if the value cannot be found.

Re-hashing the environment variables does nothing. It is provided for compatibility with Hash.

Same as ENV#delete_if, but works on (and returns) a copy of the environment.

Equivalent to ENV#delete_if but returns nil if no changes were made.

Returns an Enumerator if no block was given.

Replaces the contents of the environment variables with the contents of hash.

Returns a copy of the environment for entries where the block returns true.

Returns an Enumerator if no block was given.

Equivalent to ENV#keep_if but returns nil if no changes were made.

Removes an environment variable name-value pair from ENV and returns it as an Array. Returns nil if when the environment is empty.

Returns the number of environment variables.

Sets the environment variable name to value. If the value given is nil the environment variable is deleted. name must be a string.

Converts the environment variables into an array of names and value arrays.

ENV.to_a # => [["TERM", "xterm-color"], ["SHELL", "/bin/bash"], ...]

Creates a hash with a copy of the environment variables.

Creates a hash with a copy of the environment variables.

Returns “ENV”

Adds the contents of hash to the environment variables. If no block is specified entries with duplicate keys are overwritten, otherwise the value of each duplicate name is determined by calling the block with the key, its value from the environment and its value from the hash.

Returns true if there is an environment variable with the given value.

Returns every environment variable value as an Array

Returns an array containing the environment variable values associated with the given names. See also ENV.select.