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
#initialize(op, operands) ⇒ Operation
Returns a new instance of Operation.
290 291 292 293 294 |
# File 'lib/cel/ast/elements.rb', line 290 def initialize(op, operands) @op = op @operands = operands @type = TYPES[:any] end |
Instance Attribute Details
#op ⇒ Object (readonly)
Returns the value of attribute op.
286 287 288 |
# File 'lib/cel/ast/elements.rb', line 286 def op @op end |
#operands ⇒ Object (readonly)
Returns the value of attribute operands.
286 287 288 |
# File 'lib/cel/ast/elements.rb', line 286 def operands @operands end |
#type ⇒ Object
Returns the value of attribute type.
288 289 290 |
# File 'lib/cel/ast/elements.rb', line 288 def type @type end |
Instance Method Details
#==(other) ⇒ Object
296 297 298 299 300 301 302 303 304 |
# File 'lib/cel/ast/elements.rb', line 296 def ==(other) if other.is_a?(Array) other.size == @operands.size + 1 && other.first == @op && other.slice(1..-1).zip(@operands).all? { |x1, x2| x1 == x2 } else super end end |
#to_s ⇒ Object
306 307 308 309 310 |
# File 'lib/cel/ast/elements.rb', line 306 def to_s return "#{@op}#{@operands.first}" if @operands.size == 1 @operands.join(" #{@op} ") end |