Class: Gitlab::Ci::Pipeline::Expression::Lexeme::LogicalOperator
- Defined in:
- lib/gitlab/ci/pipeline/expression/lexeme/logical_operator.rb
Constant Summary
Constants inherited from Operator
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(left, right) ⇒ LogicalOperator
constructor
This operator class is design to handle single operators that take two arguments.
- #inspect ⇒ Object
Methods inherited from Operator
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.
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
.type ⇒ Object
27 28 29 |
# File 'lib/gitlab/ci/pipeline/expression/lexeme/logical_operator.rb', line 27 def self.type :logical_operator end |
Instance Method Details
#inspect ⇒ Object
23 24 25 |
# File 'lib/gitlab/ci/pipeline/expression/lexeme/logical_operator.rb', line 23 def inspect "#{name}(#{@left.inspect}, #{@right.inspect})" end |