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

The parent class of all AST objects that contain other AST objects. Everything but the really simple objects descend from this. It is important to note that Branch objects contain other AST objects only — if you want to contain values, use a descendent of the AST::Leaf class.

Methods

each   new  

Included Modules

Enumerable

Attributes

children  [RW] 
pin  [RW] 

Public Class methods

Initialize our object. Largely relies on the method from the base class, but also does some verification.

[Source]

    # File lib/puppet/parser/ast/branch.rb, line 22
22:         def initialize(arghash)
23:             super(arghash)
24: 
25:             # Create the hash, if it was not set at initialization time.
26:             unless defined? @children
27:                 @children = []
28:             end
29: 
30:             # Verify that we only got valid AST nodes.
31:             @children.each { |child|
32:                 unless child.is_a?(AST)
33:                     raise Puppet::DevError,
34:                         "child %s is a %s instead of ast" % [child, child.class]
35:                 end
36:             }
37:         end

Public Instance methods

Yield each contained AST node in turn. Used mostly by ‘evaluate’. This definition means that I don‘t have to override ‘evaluate’ every time, but each child of Branch will likely need to override this method.

[Source]

    # File lib/puppet/parser/ast/branch.rb, line 14
14:         def each
15:             @children.each { |child|
16:                 yield child
17:             }
18:         end

[Validate]