module ENV

Overview

ENV is a hash-like accessor for environment variables.

Example

# Set env var PORT to a default if not already set
ENV["PORT"] ||= "5000"
# Later use that env var.
puts ENV["PORT"].to_i

NOTE All keys and values are strings. You must take care to cast other types at runtime, e.g. integer port numbers.

Extended Modules

Defined in:

env.cr

Class Method Summary

Class Method Detail

def self.fetch(key, default) #

Retrieves a value corresponding to the given key. Return the second argument's value if the key does not exist.


[View source]