Module: Dotenv::Substitutions::Variable

### Home Classes Methods

### In Files

- lib/dotenv/substitutions/variable.rb

### Methods

- ::call

### Class/Module Index

Quicksearch

- Dotenv
- Dotenv::CLI
- Dotenv::Environment
- Dotenv::FormatError
- Dotenv::Parser
- Dotenv::Substitutions
- Dotenv::Substitutions::Command
- Dotenv::Substitutions::Variable

No matching classes.

# Dotenv::Substitutions::Variable

Substitute variables in a value.

    HOST=example.com
    URL="https://$HOST"

### Constants

VARIABLE

### Public Class Methods

call(value, env) click to toggle source

    # File lib/dotenv/substitutions/variable.rb, line 20
    def call(value, env)
      value.gsub(VARIABLE) do |variable|
        match = $LAST_MATCH_INFO

        if match[1] == '\'
          variable[1..-1]
        else
          env.fetch(match[3]) { ENV[match[3]] }
        end
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.