Class: Puppet::Parser::AST::BlockExpression
- Includes:
- Enumerable
- Defined in:
- lib/puppet/parser/ast/block_expression.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Branch
Instance Method Summary collapse
-
#[](index) ⇒ Object
Return a child by index.
-
#evaluate(scope) ⇒ Object
Evaluate contained expressions, produce result of the last.
- #push(*ary) ⇒ Object
- #sequence_with(other) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Branch
Constructor Details
This class inherits a constructor from Puppet::Parser::AST::Branch
Instance Method Details
#[](index) ⇒ Object
Return a child by index.
22 23 24 |
# File 'lib/puppet/parser/ast/block_expression.rb', line 22 def [](index) @children[index] end |
#evaluate(scope) ⇒ Object
Evaluate contained expressions, produce result of the last
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/puppet/parser/ast/block_expression.rb', line 8 def evaluate(scope) result = nil @children.each do |child| # Skip things that respond to :instantiate (classes, nodes, # and definitions), because they have already been # instantiated. if !child.respond_to?(:instantiate) result = child.safeevaluate(scope) end end result end |
#push(*ary) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/puppet/parser/ast/block_expression.rb', line 26 def push(*ary) ary.each { |child| #Puppet.debug "adding %s(%s) of type %s to %s" % # [child, child.object_id, child.class.to_s.sub(/.+::/,''), # self.object_id] @children.push(child) } self end |
#sequence_with(other) ⇒ Object
37 38 39 |
# File 'lib/puppet/parser/ast/block_expression.rb', line 37 def sequence_with(other) Puppet::Parser::AST::BlockExpression.new(:children => self.children + other.children) end |
#to_s ⇒ Object
41 42 43 |
# File 'lib/puppet/parser/ast/block_expression.rb', line 41 def to_s "[" + @children.collect { |c| c.to_s }.join(', ') + "]" end |