summaryrefslogtreecommitdiff
path: root/deployment_scripts/puppet/files/embedded/lib/ruby/gems/2.3.0/gems/dentaku-2.0.9/lib/dentaku/ast/comparators.rb
blob: c7c9ee049381d93da0d4241b0731b2008860bc3b (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require_relative './operation'

module Dentaku
  module AST
    class Comparator < Operation
      def self.precedence
        5
      end

      def type
        :logical
      end
    end

    class LessThan < Comparator
      def value(context={})
        left.value(context) < right.value(context)
      end
    end

    class LessThanOrEqual < Comparator
      def value(context={})
        left.value(context) <= right.value(context)
      end
    end

    class GreaterThan < Comparator
      def value(context={})
        left.value(context) > right.value(context)
      end
    end

    class GreaterThanOrEqual < Comparator
      def value(context={})
        left.value(context) >= right.value(context)
      end
    end

    class NotEqual < Comparator
      def value(context={})
        left.value(context) != right.value(context)
      end
    end

    class Equal < Comparator
      def value(context={})
        left.value(context) == right.value(context)
      end
    end
  end
end