Class: Puppet::Parser::AST::BlockExpression

Inherits:
Branch show all
Defined in:
lib/puppet/parser/ast/block_expression.rb

Overview

Evaluates contained expressions, produce result of the last

Constant Summary

Constants inherited from Puppet::Parser::AST

AST

Instance Attribute Summary

Attributes inherited from Branch

#children, #pin

Attributes inherited from Puppet::Parser::AST

#file, #line, #parent, #pos, #scope

Instance Method Summary collapse

Methods inherited from Branch

#each, #initialize

Methods included from Enumerable

#uniq

Methods inherited from Puppet::Parser::AST

#initialize, #inspect, #safeevaluate

Methods included from Util::Errors

#adderrorcontext, #devfail, #error_context, error_location, error_location_with_space, error_location_with_unknowns, #exceptwrap, #fail

Constructor Details

This class inherits a constructor from Puppet::Parser::AST::Branch

Instance Method Details

#evaluate(scope) ⇒ Object



4
5
6
# File 'lib/puppet/parser/ast/block_expression.rb', line 4

def evaluate(scope)
  @children.reduce(nil) { |_, child| child.safeevaluate(scope) }
end

#sequence_with(other) ⇒ Object



8
9
10
# File 'lib/puppet/parser/ast/block_expression.rb', line 8

def sequence_with(other)
  Puppet::Parser::AST::BlockExpression.new(:children => self.children + other.children)
end

#to_sObject



12
13
14
# File 'lib/puppet/parser/ast/block_expression.rb', line 12

def to_s
  "[" + @children.collect { |c| c.to_s }.join(', ') + "]"
end