Class: Cel::Invoke
- Inherits:
-
Object
- Object
- Cel::Invoke
- Defined in:
- lib/cel/ast/elements.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#func ⇒ Object
readonly
Returns the value of attribute func.
-
#var ⇒ Object
readonly
Returns the value of attribute var.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(func:, var: nil, args: nil) ⇒ Invoke
constructor
A new instance of Invoke.
- #to_s ⇒ Object
Constructor Details
#initialize(func:, var: nil, args: nil) ⇒ Invoke
Returns a new instance of Invoke.
44 45 46 47 48 |
# File 'lib/cel/ast/elements.rb', line 44 def initialize(func:, var: nil, args: nil) @var = var @func = func.to_sym @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
42 43 44 |
# File 'lib/cel/ast/elements.rb', line 42 def args @args end |
#func ⇒ Object (readonly)
Returns the value of attribute func.
42 43 44 |
# File 'lib/cel/ast/elements.rb', line 42 def func @func end |
#var ⇒ Object (readonly)
Returns the value of attribute var.
42 43 44 |
# File 'lib/cel/ast/elements.rb', line 42 def var @var end |
Instance Method Details
#==(other) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/cel/ast/elements.rb', line 50 def ==(other) super || ( other.respond_to?(:to_ary) && [@var, @func, @args].compact == other ) end |
#to_s ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/cel/ast/elements.rb', line 57 def to_s if var if func == :[] "#{var}[#{args}]" else "#{var}.#{func}#{"(#{args.map(&:to_s).join(", ")})" if args}" end else "#{func}#{"(#{args.map(&:to_s).join(", ")})" if args}" end end |