Class: Ruby::Rego::AST::BinaryOp

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby/rego/ast/binary_op.rb

Overview

Represents a binary operation.

Constant Summary collapse

OPERATORS =
%i[
  eq
  neq
  and
  or
  lt
  lte
  gt
  gte
  in
  plus
  minus
  mult
  div
  mod
  assign
  unify
].freeze

Instance Attribute Summary collapse

Attributes inherited from Base

#location

Instance Method Summary collapse

Methods inherited from Base

#==, #accept, #deconstruct_keys, #eql?, format_value, #hash, #to_s

Constructor Details

#initialize(operator:, left:, right:, location: nil) ⇒ BinaryOp

Returns a new instance of BinaryOp.

Parameters:

  • operator (Symbol)
  • left (Object)
  • right (Object)
  • location (Location, nil) (defaults to: nil)


33
34
35
36
37
38
39
# File 'lib/ruby/rego/ast/binary_op.rb', line 33

def initialize(operator:, left:, right:, location: nil)
  @operator = operator
  validate_operator!
  super(location: location)
  @left = left
  @right = right
end

Instance Attribute Details

#leftObject (readonly)

Returns:

  • (Object)


45
46
47
# File 'lib/ruby/rego/ast/binary_op.rb', line 45

def left
  @left
end

#operatorSymbol (readonly)

Returns:

  • (Symbol)


42
43
44
# File 'lib/ruby/rego/ast/binary_op.rb', line 42

def operator
  @operator
end

#rightObject (readonly)

Returns:

  • (Object)


48
49
50
# File 'lib/ruby/rego/ast/binary_op.rb', line 48

def right
  @right
end