| 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.
Return a child by index. Probably never used.
# File lib/puppet/parser/ast/astarray.rb, line 13
13: def [](index)
14: @children[index]
15: end
Evaluate our children.
# 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