Class: CSVPlusPlus::Entities::Function
- Inherits:
-
EntityWithArguments
- Object
- Entity
- EntityWithArguments
- CSVPlusPlus::Entities::Function
- Defined in:
- lib/csv_plus_plus/entities/function.rb
Overview
A function definition
from @arguments
Instance Attribute Summary collapse
-
#body ⇒ Entity
readonly
The body of the function.
Attributes inherited from EntityWithArguments
Attributes inherited from Entity
Instance Method Summary collapse
- #==(other) ⇒ boolean
-
#initialize(id, arguments, body) ⇒ Function
constructor
A new instance of Function.
- #to_s ⇒ String
Methods inherited from Entity
#method_missing, #respond_to_missing?
Constructor Details
#initialize(id, arguments, body) ⇒ Function
Returns a new instance of Function.
17 18 19 20 |
# File 'lib/csv_plus_plus/entities/function.rb', line 17 def initialize(id, arguments, body) super(:function, id:, arguments: arguments.map(&:to_sym)) @body = body end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class CSVPlusPlus::Entities::Entity
Instance Attribute Details
#body ⇒ Entity (readonly)
The body of the function. body can contain variable references
11 12 13 |
# File 'lib/csv_plus_plus/entities/function.rb', line 11 def body @body end |
Instance Method Details
#==(other) ⇒ boolean
28 29 30 |
# File 'lib/csv_plus_plus/entities/function.rb', line 28 def ==(other) super && @body == other.body end |
#to_s ⇒ String
23 24 25 |
# File 'lib/csv_plus_plus/entities/function.rb', line 23 def to_s "def #{@id.to_s.upcase}(#{arguments_to_s}) #{@body}" end |