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
- #unary? ⇒ Boolean
Constructor Details
Instance Attribute Details
#op ⇒ Object (readonly)
Returns the value of attribute op.
541 542 543 |
# File 'lib/cel/ast/elements.rb', line 541 def op @op end |
#operands ⇒ Object (readonly)
Returns the value of attribute operands.
541 542 543 |
# File 'lib/cel/ast/elements.rb', line 541 def operands @operands end |
#type ⇒ Object
Returns the value of attribute type.
543 544 545 |
# File 'lib/cel/ast/elements.rb', line 543 def type @type end |
Instance Method Details
#==(other) ⇒ Object
551 552 553 554 555 556 557 558 559 560 561 562 |
# File 'lib/cel/ast/elements.rb', line 551 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
568 569 570 571 572 |
# File 'lib/cel/ast/elements.rb', line 568 def to_s return "#{@op}#{@operands.first}" if @operands.size == 1 @operands.join(" #{@op} ") end |
#unary? ⇒ Boolean
564 565 566 |
# File 'lib/cel/ast/elements.rb', line 564 def unary? @operands.size == 1 end |