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:             rets = items.flatten.collect { |child|
34:                 child.safeevaluate(scope)
35:             }.flatten
36:             return rets.reject { |o| o.nil? }
37:         end

[Source]

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

[Validate]