Class: Code::Node::Call
- Inherits:
-
Code::Node
- Object
- Code::Node
- Code::Node::Call
- Defined in:
- lib/code/node/call.rb
Defined Under Namespace
Classes: Block
Instance Method Summary collapse
- #evaluate(**args) ⇒ Object
-
#initialize(parsed) ⇒ Call
constructor
A new instance of Call.
- #resolve(**_args) ⇒ Object
Constructor Details
#initialize(parsed) ⇒ Call
Returns a new instance of Call.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/code/node/call.rb', line 25 def initialize(parsed) @name = parsed.delete(:name) @arguments = parsed .delete(:arguments) { [] } .map { |argument| CallArgument.new(argument) } @block = Call::Block.new(parsed.delete(:block)) if parsed.key?(:block) super(parsed) end |
Instance Method Details
#evaluate(**args) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/code/node/call.rb', line 37 def evaluate(**args) arguments = [] @arguments.each do |argument| if argument.keyword? if arguments.last&.value.is_a?(Object::Dictionary) arguments.last.value[argument.name] = argument.evaluate( **args ).value else arguments << Object::Argument.new( Object::Dictionary.new( { argument.name => argument.evaluate(**args).value } ) ) end else arguments << argument.evaluate(**args) end end arguments << @block.evaluate(**args) if @block name = Object::String.new(@name) args.fetch(:object).call(operator: name, arguments:, **args) end |