11. Environment Variables
Nekonote::Env class provides the way to get Environment Variables.
The detail for environment variables is please see the following link, the documentation of Rack.
Nekonote::Env class
Nekonote::Env is a class to get some value of environment variable.
Here is a list of the class methods defined in Nekonote::Env class.
| Nekonote::Env.get | Returns the value by a specific key_name. |
| Nekonote::Env.keys | Returns a list of keys for Nekonote::Env.get. |
| Nekonote::Env.get_all | Returns all environment variable. |
| Nekonote::Env.root | Returns the application root. |
| Nekonote::Env.current | Returns the current environment (NEKONOTE_ENV). |
Nekonote::Env.get(key_name)
Returns the value by a specific key_name.
| parameter | type | required | description |
|---|---|---|---|
| key_name | string or symbol | yes | A key name (variable name) to get from environment variables. |
Return Values:
It returns string when the given key_name was found.
It returns nil if the given key_name was not found or given no key_name.
e.g.
# Get the query string
Nekonote::Env.get :QUERY_STRING
Nekonote::Env.keys
Returns a list of keys for Nekonote::Env.get.
Return Values:
It returns array.
Nekonote::Env.get_all
Returns all environment variable.
Return Values:
It returns hash.
Nekonote::Env.root
Returns the application root.
Return Values:
It returns string.
Nekonote::Env.current
Returns the current envinronment (NEKONOTE_ENV).
Return Values:
It returns string.