Class: Gitlab::Ci::Pipeline::Expression::Lexeme::LogicalOperator

Inherits:
Operator
  • Object
show all
Defined in:
lib/gitlab/ci/pipeline/expression/lexeme/logical_operator.rb

Direct Known Subclasses

And, Equals, Matches, NotEquals, NotMatches, Or

Constant Summary

Constants inherited from Operator

Operator::OperatorError

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Operator

precedence

Methods inherited from Base

build, consume?, #evaluate, #name, pattern, scan

Constructor Details

#initialize(left, right) ⇒ LogicalOperator

This operator class is design to handle single operators that take two arguments. Expression::Parser was originally designed to read infix operators, and so the two operands are called “left” and “right” here. If we wish to implement an Operator that takes a greater or lesser number of arguments, a structural change or additional Operator superclass will likely be needed.

Raises:


15
16
17
18
19
20
21
# File 'lib/gitlab/ci/pipeline/expression/lexeme/logical_operator.rb', line 15

def initialize(left, right)
  raise OperatorError, 'Invalid left operand' unless left.respond_to? :evaluate
  raise OperatorError, 'Invalid right operand' unless right.respond_to? :evaluate

  @left = left
  @right = right
end

Class Method Details

.typeObject


27
28
29
# File 'lib/gitlab/ci/pipeline/expression/lexeme/logical_operator.rb', line 27

def self.type
  :logical_operator
end

Instance Method Details

#inspectObject


23
24
25
# File 'lib/gitlab/ci/pipeline/expression/lexeme/logical_operator.rb', line 23

def inspect
  "#{name}(#{@left.inspect}, #{@right.inspect})"
end