Class: Puppet::Parser::AST::Branch

Inherits:
Puppet::Parser::AST show all
Includes:
Enumerable
Defined in:
lib/vendor/puppet/parser/ast/branch.rb

Overview

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.

Constant Summary

Constants inherited from Puppet::Parser::AST

AST

Constants included from Util::Docs

Util::Docs::HEADER_LEVELS

Instance Attribute Summary collapse

Attributes inherited from Puppet::Parser::AST

#file, #line, #parent, #scope

Attributes included from Util::Docs

#doc, #nodoc

Instance Method Summary collapse

Methods inherited from Puppet::Parser::AST

associates_doc, #evaluate, #evaluate_match, #inspect, #parsefail, #parsewrap, #safeevaluate, settor?, #use_docs

Methods included from Util::Docs

#desc, #dochook, #doctable, #markdown_definitionlist, #markdown_header, #nodoc?, #pad, scrub

Methods included from Util::MethodHelper

#requiredopts, #set_options, #symbolize_options

Methods included from Util::Errors

#adderrorcontext, #devfail, #error_context, #exceptwrap, #fail

Constructor Details

#initialize(arghash) ⇒ Branch

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



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/vendor/puppet/parser/ast/branch.rb', line 22

def initialize(arghash)
  super(arghash)

  # Create the hash, if it was not set at initialization time.
  @children ||= []

  # Verify that we only got valid AST nodes.
  @children.each { |child|
    unless child.is_a?(AST)
      raise Puppet::DevError,
        "child #{child} is a #{child.class} instead of ast"
    end
  }
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



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

def children
  @children
end

#pinObject

Returns the value of attribute pin.



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

def pin
  @pin
end

Instance Method Details

#eachObject

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.



14
15
16
17
18
# File 'lib/vendor/puppet/parser/ast/branch.rb', line 14

def each
  @children.each { |child|
    yield child
  }
end