Class: Cel::Operation
- Inherits:
-
Object
- Object
- Cel::Operation
- Defined in:
- lib/cel/ast/elements.rb
Instance Attribute Summary collapse
-
#op ⇒ Object
readonly
Returns the value of attribute op.
-
#operands ⇒ Object
readonly
Returns the value of attribute operands.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(op, operands) ⇒ Operation
constructor
A new instance of Operation.
- #to_s ⇒ Object
Constructor Details
Instance Attribute Details
#op ⇒ Object (readonly)
Returns the value of attribute op.
521 522 523 |
# File 'lib/cel/ast/elements.rb', line 521 def op @op end |
#operands ⇒ Object (readonly)
Returns the value of attribute operands.
521 522 523 |
# File 'lib/cel/ast/elements.rb', line 521 def operands @operands end |
#type ⇒ Object
Returns the value of attribute type.
523 524 525 |
# File 'lib/cel/ast/elements.rb', line 523 def type @type end |
Instance Method Details
#==(other) ⇒ Object
531 532 533 534 535 536 537 538 539 540 541 542 |
# File 'lib/cel/ast/elements.rb', line 531 def ==(other) case other when Array other.size == @operands.size + 1 && other.first == @op && other.slice(1..-1).zip(@operands).all? { |x1, x2| x1 == x2 } when Operation @op == other.op && @type == other.type && @operands == other.operands else super end end |
#to_s ⇒ Object
544 545 546 547 548 |
# File 'lib/cel/ast/elements.rb', line 544 def to_s return "#{@op}#{@operands.first}" if @operands.size == 1 @operands.join(" #{@op} ") end |