Sha256: e456f4798fe4dbc0edce403abeaded7e4ceddd7caac8da85acc6c633f0b77448

Contents?: true

Size: 1.4 KB

Versions: 16

Compression:

Stored size: 1.4 KB

Contents

class Puppet::Parser::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.
    class Branch < AST
        include Enumerable
        attr_accessor :pin, :children

        # 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.
        def each
            @children.each { |child|
                yield child
            }
        end

        # Initialize our object.  Largely relies on the method from the base
        # class, but also does some verification.
        def initialize(arghash)
            super(arghash)

            # Create the hash, if it was not set at initialization time.
            unless defined? @children
                @children = []
            end

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

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
puppet-0.25.5 lib/puppet/parser/ast/branch.rb
puppet-0.25.4 lib/puppet/parser/ast/branch.rb
puppet-0.25.3 lib/puppet/parser/ast/branch.rb
puppet-0.24.9 lib/puppet/parser/ast/branch.rb
puppet-0.25.2 lib/puppet/parser/ast/branch.rb
puppet-0.25.1 lib/puppet/parser/ast/branch.rb
puppet-0.25.0 lib/puppet/parser/ast/branch.rb
puppet-0.24.0 lib/puppet/parser/ast/branch.rb
puppet-0.24.4 lib/puppet/parser/ast/branch.rb
puppet-0.24.1 lib/puppet/parser/ast/branch.rb
puppet-0.24.3 lib/puppet/parser/ast/branch.rb
puppet-0.24.2 lib/puppet/parser/ast/branch.rb
puppet-0.24.6 lib/puppet/parser/ast/branch.rb
puppet-0.24.5 lib/puppet/parser/ast/branch.rb
puppet-0.24.7 lib/puppet/parser/ast/branch.rb
puppet-0.24.8 lib/puppet/parser/ast/branch.rb