Class: CSVPlusPlus::Entities::FunctionCall
- Inherits:
-
EntityWithArguments
- Object
- Entity
- EntityWithArguments
- CSVPlusPlus::Entities::FunctionCall
- Extended by:
- T::Sig
- Defined in:
- lib/csv_plus_plus/entities/function_call.rb
Overview
A function call that can be either infix (A + B) or prefix (ADD(A, B))
Instance Attribute Summary collapse
-
#infix ⇒ boolean
readonly
Whether or not this function call is infix (X * Y, A + B, etc).
Attributes inherited from EntityWithArguments
Attributes inherited from Entity
Instance Method Summary collapse
- #==(other) ⇒ boolean
- #evaluate(runtime) ⇒ ::String
-
#initialize(id, arguments, infix: false) ⇒ FunctionCall
constructor
A new instance of FunctionCall.
Constructor Details
#initialize(id, arguments, infix: false) ⇒ FunctionCall
Returns a new instance of FunctionCall.
19 20 21 22 23 |
# File 'lib/csv_plus_plus/entities/function_call.rb', line 19 def initialize(id, arguments, infix: false) super(::CSVPlusPlus::Entities::Type::FunctionCall, id:, arguments:) @infix = infix end |
Instance Attribute Details
#infix ⇒ boolean (readonly)
Whether or not this function call is infix (X * Y, A + B, etc)
9 10 11 |
# File 'lib/csv_plus_plus/entities/function_call.rb', line 9 def infix @infix end |
Instance Method Details
#==(other) ⇒ boolean
43 44 45 46 47 |
# File 'lib/csv_plus_plus/entities/function_call.rb', line 43 def ==(other) return false unless super other.is_a?(self.class) && @id == other.id && @infix == other.infix end |
#evaluate(runtime) ⇒ ::String
29 30 31 32 33 34 35 36 37 |
# File 'lib/csv_plus_plus/entities/function_call.rb', line 29 def evaluate(runtime) evaluated_arguments = evaluate_arguments(runtime) if @infix "(#{evaluated_arguments.join(" #{@id} ")})" else "#{@id.to_s.upcase}(#{evaluated_arguments.join(', ')})" end end |