Module: ExpandVariables

Defined in:
lib/expand_variables.rb

Constant Summary collapse

VARIABLES_REGEXP =
/\$([a-zA-Z_][a-zA-Z0-9_]*)|\${\g<1>}|%\g<1>%/.freeze

Class Method Summary collapse

Class Method Details

.expand(value, variables) ⇒ Object


7
8
9
10
11
# File 'lib/expand_variables.rb', line 7

def expand(value, variables)
  replace_with(value, variables) do |vars_hash, last_match|
    match_or_blank_value(vars_hash, last_match)
  end
end

.expand_existing(value, variables) ⇒ Object


13
14
15
16
17
# File 'lib/expand_variables.rb', line 13

def expand_existing(value, variables)
  replace_with(value, variables) do |vars_hash, last_match|
    match_or_original_value(vars_hash, last_match)
  end
end