Class: Code::Node::CallArgument

Inherits:
Code::Node show all
Defined in:
lib/code/node/call_argument.rb

Instance Method Summary collapse

Methods inherited from Code::Node

#resolve

Constructor Details

#initialize(parsed) ⇒ CallArgument

Returns a new instance of CallArgument.



6
7
8
9
10
11
# File 'lib/code/node/call_argument.rb', line 6

def initialize(parsed)
  return if parsed.blank?

  @value = Node::Code.new(parsed.delete(:value).presence)
  @name = parsed.delete(:name).presence
end

Instance Method Details

#evaluate(**args) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/code/node/call_argument.rb', line 13

def evaluate(**args)
  if @name
    Object::Dictionary.new(
      name => @value&.evaluate(**args) || Object::Nothing.new
    )
  else
    @value&.evaluate(**args) || Object::Nothing.new
  end
end

#keyword?Boolean

Returns:



23
24
25
# File 'lib/code/node/call_argument.rb', line 23

def keyword?
  !!@name
end

#nameObject



31
32
33
# File 'lib/code/node/call_argument.rb', line 31

def name
  Object::String.new(@name)
end

#regular?Boolean

Returns:



27
28
29
# File 'lib/code/node/call_argument.rb', line 27

def regular?
  !keyword?
end