Class Puppet::Parser::AST::ASTArray
In: lib/puppet/parser/ast/astarray.rb
Parent: Branch

The basic container class. This object behaves almost identically to a normal array except at initialization time. Note that its name is ‘AST::ASTArray’, rather than plain ‘AST::Array’; I had too many bugs when it was just ‘AST::Array’, because things like ‘object.is_a?(Array)’ never behaved as I expected.

Methods

[]   evaluate   push  

Included Modules

Enumerable

Public Instance methods

Return a child by index. Probably never used.

[Source]

    # File lib/puppet/parser/ast/astarray.rb, line 13
13:         def [](index)
14:             @children[index]
15:         end

Evaluate our children.

[Source]

    # File lib/puppet/parser/ast/astarray.rb, line 18
18:         def evaluate(scope)
19:             # Make a new array, so we don't have to deal with the details of
20:             # flattening and such
21:             items = []
22:             
23:             # First clean out any AST::ASTArrays
24:             @children.each { |child|
25:                 if child.instance_of?(AST::ASTArray)
26:                     child.each do |ac|
27:                         items << ac
28:                     end
29:                 else
30:                     items << child
31:                 end
32:             }
33: 
34:             rets = items.flatten.collect { |child|
35:                 child.safeevaluate(scope)
36:             }
37:             return rets.reject { |o| o.nil? }
38:         end

[Source]

    # File lib/puppet/parser/ast/astarray.rb, line 40
40:         def push(*ary)
41:             ary.each { |child|
42:                 #Puppet.debug "adding %s(%s) of type %s to %s" %
43:                 #    [child, child.object_id, child.class.to_s.sub(/.+::/,''),
44:                 #    self.object_id]
45:                 @children.push(child)
46:             }
47: 
48:             return self
49:         end

[Validate]