module Env

Constants

VERSION

env version

Public Class Methods

[](name) click to toggle source

Provides direct access to the environment variables.

@param [String, Symbol] name

The name of the environment variable.

@return [String, nil]

The value of the environment variable.

@example

Env['SHELL']
# => "/bin/bash"
# File lib/env/env.rb, line 19
def Env.[](name)
  env[name.to_s]
end
[]=(name,value) click to toggle source

Sets an environment variable.

@param [String, Symbol] name

The name of the environment variable.

@param [Object] value

The value of the environment variable.

@return [String]

The String value of the environment variable.
# File lib/env/env.rb, line 35
def Env.[]=(name,value)
  env[name.to_s] = value.to_s
end

Protected Class Methods

const_missing(name) click to toggle source

Provides transparent access to the environment variables.

@param [Symbol] name

The name of the environment variable.

@return [String, nil]

The value of the environment variable.

@example

Env::SHELL
# => "/bin/bash"
# File lib/env/env.rb, line 54
def Env.const_missing(name)
  Env[name.to_s]
end
method_missing(name,*arguments,&block) click to toggle source

Provides transparent access to the environment variables.

@param [Symbol] name

The name of the environment variable.

@return [String, nil]

The value of the environment variable.

@example

Env.shell
# => "/bin/bash"

@example

Env.shell = '/bin/zsh'
# => "/bin/zsh"
Calls superclass method
# File lib/env/env.rb, line 75
def Env.method_missing(name,*arguments,&block)
  name = name.to_s

  if (arguments.length == 1 && name[-1..-1] == '=')
    name.chop!
    name.upcase!

    return Env[name] = arguments.first
  elsif arguments.empty?
    name.upcase!

    return Env[name]
  end

  super(name,*arguments,&block)
end