Class: Puppet::Parser::AST::Variable

Inherits:
Name show all
Defined in:
lib/puppet/parser/ast/leaf.rb

Overview

A simple variable. This object is only used during interpolation; the VarDef class is used for assignment.

Instance Attribute Summary

Attributes inherited from Leaf

#type, #value

Instance Method Summary collapse

Methods inherited from Leaf

#match

Instance Method Details

#evaluate(scope) ⇒ Object

Looks up the value of the object in the scope tree (does not include syntactical constructs, like ‘$’ and ‘{}’).



114
115
116
117
118
119
120
121
122
# File 'lib/puppet/parser/ast/leaf.rb', line 114

def evaluate(scope)
  parsewrap do
    if scope.include?(@value)
      scope[@value, {:file => file, :line => line}]
    else
      :undef
    end
  end
end

#to_sObject



124
125
126
# File 'lib/puppet/parser/ast/leaf.rb', line 124

def to_s
  "\$#{value}"
end