summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/ast/else.rb
blob: ff2f233b7f0dd4d63594484cb791b0a4582f8e6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require 'puppet/parser/ast/branch'

class Puppet::Parser::AST
    # A separate ElseIf statement; can function as an 'else' if there's no
    # test.
    class Else < AST::Branch
        attr_accessor :statements

        def each
            yield @statements
        end

        # Evaluate the actual statements; this only gets called if
        # our test was true matched.
        def evaluate(hash)
            scope = hash[:scope]
            return @statements.safeevaluate(:scope => scope)
        end

        def tree(indent = 0)
            rettree = [
                ((@@indline * indent) + self.typewrap(self.pin)),
                @statements.tree(indent + 1)
            ]
            return rettree.flatten.join("\n")
        end
    end
end

# $Id$