Sha256: d2933d8739cc57eda7267c7a0541f9987d3269d4c51b475b2abecf51782b0778

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

require 'puppet/parser/ast/branch'

class Puppet::Parser::AST
    # Define a variable.  Stores the value in the current scope.
    class VarDef < AST::Branch
        attr_accessor :name, :value

        @settor = true

        # Look up our name and value, and store them appropriately.  The
        # lexer strips off the syntax stuff like '$'.
        def evaluate(hash)
            scope = hash[:scope]
            name = @name.safeevaluate(:scope => scope)
            value = @value.safeevaluate(:scope => scope)

            parsewrap do
                scope.setvar(name,value, @file, @line)
            end
        end

        def each
            [@name,@value].each { |child| yield child }
        end

        def tree(indent = 0)
            return [
                @name.tree(indent + 1),
                ((@@indline * 4 * indent) + self.typewrap(self.pin)),
                @value.tree(indent + 1)
            ].join("\n")
        end

        def to_s
            return "%s => %s" % [@name,@value]
        end
    end

end

# $Id: vardef.rb 2237 2007-02-28 00:07:41Z luke $

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
puppet-0.22.4 lib/puppet/parser/ast/vardef.rb
puppet-0.23.0 lib/puppet/parser/ast/vardef.rb
puppet-0.23.2 lib/puppet/parser/ast/vardef.rb
puppet-0.23.1 lib/puppet/parser/ast/vardef.rb