Class: Gitlab::Ci::Pipeline::Expression::Lexeme::LogicalOperator
- Defined in:
- lib/gitlab/ci/pipeline/expression/lexeme/logical_operator.rb
Constant Summary
Constants inherited from Operator
Instance Attribute Summary collapse
-
#left ⇒ Object
readonly
This operator class is design to handle single operators that take two arguments.
-
#right ⇒ Object
readonly
This operator class is design to handle single operators that take two arguments.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(left, right) ⇒ LogicalOperator
constructor
A new instance of LogicalOperator.
- #inspect ⇒ Object
Methods inherited from Operator
Methods inherited from Base
build, consume?, #evaluate, #name, pattern, scan
Constructor Details
#initialize(left, right) ⇒ LogicalOperator
Returns a new instance of LogicalOperator.
17 18 19 20 21 22 23 |
# File 'lib/gitlab/ci/pipeline/expression/lexeme/logical_operator.rb', line 17 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 |
Instance Attribute Details
#left ⇒ Object (readonly)
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 |
# File 'lib/gitlab/ci/pipeline/expression/lexeme/logical_operator.rb', line 15 def left @left end |
#right ⇒ Object (readonly)
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 |
# File 'lib/gitlab/ci/pipeline/expression/lexeme/logical_operator.rb', line 15 def right @right end |
Class Method Details
.type ⇒ Object
29 30 31 |
# File 'lib/gitlab/ci/pipeline/expression/lexeme/logical_operator.rb', line 29 def self.type :logical_operator end |
Instance Method Details
#inspect ⇒ Object
25 26 27 |
# File 'lib/gitlab/ci/pipeline/expression/lexeme/logical_operator.rb', line 25 def inspect "#{name}(#{@left.inspect}, #{@right.inspect})" end |