Module: Gobstones::Lang::DefinitionCall
- Includes:
- EqualityDefinition
- Included in:
- Commands::ProcedureCall, FunctionCall
- Defined in:
- lib/gobstones/lang/definitions/definition_call.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #equality_attributes ⇒ Object
- #evaluate(context) ⇒ Object
- #initialize(name, arguments = []) ⇒ Object
Methods included from EqualityDefinition
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
9 10 11 |
# File 'lib/gobstones/lang/definitions/definition_call.rb', line 9 def arguments @arguments end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/gobstones/lang/definitions/definition_call.rb', line 9 def name @name end |
Instance Method Details
#equality_attributes ⇒ Object
16 17 18 |
# File 'lib/gobstones/lang/definitions/definition_call.rb', line 16 def equality_attributes %i[name arguments] end |
#evaluate(context) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/gobstones/lang/definitions/definition_call.rb', line 20 def evaluate(context) evaluated_arguments = arguments.map { |argument| argument.evaluate(context) } context.program_context.definition_named(name, ->(definition) { definition.evaluate context, evaluated_arguments }, -> { raise Runner::DefinitionNotFound, name }) end |
#initialize(name, arguments = []) ⇒ Object
11 12 13 14 |
# File 'lib/gobstones/lang/definitions/definition_call.rb', line 11 def initialize(name, arguments = []) @name = name @arguments = arguments end |