class Warg::Script::Interpolations

Constants

CONTEXT_REGEXP

Public Class Methods

new(context) click to toggle source
# File lib/warg.rb, line 2121
def initialize(context)
  @context = context
  @values = {}
end

Public Instance Methods

[](key) click to toggle source
# File lib/warg.rb, line 2134
def [](key)
  if @values.key?(key)
    @values[key]
  elsif key =~ CONTEXT_REGEXP && @context.variables_set_defined?($1)
    variables = @context[$1]
    content = variables.to_h.sort.map { |key, value| %{#{key}="#{value}"} }.join("\n")

    @values[key] = content
  end
end
[]=(key, value) click to toggle source
# File lib/warg.rb, line 2145
def []=(key, value)
  @values[key] = value
end
key?(key) click to toggle source
# File lib/warg.rb, line 2126
def key?(key)
  if key =~ CONTEXT_REGEXP
    @context.variables_set_defined?($1)
  else
    @values.key?(key)
  end
end