summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/ast/minus.rb
blob: b0779a8eef091976714d26c1f0556dd6816a1929 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'puppet'
require 'puppet/parser/ast/branch'

# An object that returns a boolean which is the boolean not
# of the given value.
class Puppet::Parser::AST
    class Minus < AST::Branch
        attr_accessor :value

        def each
            yield @value
        end

        def evaluate(scope)
            val = @value.safeevaluate(scope)
            val = Puppet::Parser::Scope.number?(val)
            if val == nil
                raise ArgumentError, "minus operand %s is not a number" % val
            end
            return -val
        end
    end
end