Class: CSVPlusPlus::Entities::FunctionCall
- Inherits:
-
EntityWithArguments
- Object
- Entity
- EntityWithArguments
- CSVPlusPlus::Entities::FunctionCall
- Extended by:
- T::Sig
- Includes:
- HasIdentifier
- 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))
Constant Summary collapse
- ArgumentsType =
type_member { { fixed: ::CSVPlusPlus::Entities::Entity } }
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#infix ⇒ boolean
readonly
Whether or not this function call is infix (X * Y, A + B, etc).
Attributes inherited from EntityWithArguments
Instance Method Summary collapse
- #==(other) ⇒ Boolean
- #evaluate(position) ⇒ ::String
-
#initialize(id, arguments, infix: false) ⇒ FunctionCall
constructor
A new instance of FunctionCall.
Methods included from HasIdentifier
Constructor Details
#initialize(id, arguments, infix: false) ⇒ FunctionCall
Returns a new instance of FunctionCall.
32 33 34 35 36 37 |
# File 'lib/csv_plus_plus/entities/function_call.rb', line 32 def initialize(id, arguments, infix: false) super(arguments:) @id = ::T.let(identifier(id), ::Symbol) @infix = infix end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
20 21 22 |
# File 'lib/csv_plus_plus/entities/function_call.rb', line 20 def id @id end |
#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
57 58 59 60 61 62 63 64 |
# File 'lib/csv_plus_plus/entities/function_call.rb', line 57 def ==(other) case other when self.class @id == other.id && @infix == other.infix else false end end |
#evaluate(position) ⇒ ::String
43 44 45 46 47 48 49 50 51 |
# File 'lib/csv_plus_plus/entities/function_call.rb', line 43 def evaluate(position) evaluated_arguments = evaluate_arguments(position) if @infix "(#{evaluated_arguments.join(" #{@id} ")})" else "#{@id.to_s.upcase}(#{evaluated_arguments.join(', ')})" end end |