Class: YARP::ReturnNode

Inherits:
YARPNode
  • Object
show all
Defined in:
lib/yarp/node.rb,
ext/yarp/api_node.c

Overview

Represents the use of the ‘return` keyword.

return 1
^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keyword_loc, arguments, location) ⇒ ReturnNode

def initialize: (keyword_loc: Location, arguments: Node?, location: Location) -> void



5448
5449
5450
5451
5452
# File 'lib/yarp/node.rb', line 5448

def initialize(keyword_loc, arguments, location)
  @keyword_loc = keyword_loc
  @arguments = arguments
  @location = location
end

Instance Attribute Details

#argumentsObject (readonly)

attr_reader arguments: Node?



5445
5446
5447
# File 'lib/yarp/node.rb', line 5445

def arguments
  @arguments
end

#keyword_locObject (readonly)

attr_reader keyword_loc: Location



5442
5443
5444
# File 'lib/yarp/node.rb', line 5442

def keyword_loc
  @keyword_loc
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



5455
5456
5457
# File 'lib/yarp/node.rb', line 5455

def accept(visitor)
  visitor.visit_return_node(self)
end

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array[nil | Node]



5460
5461
5462
# File 'lib/yarp/node.rb', line 5460

def child_nodes
  [arguments]
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (keys: Array) -> Hash[Symbol, nil | Node | Array | String | Token | Array | Location]



5468
5469
5470
# File 'lib/yarp/node.rb', line 5468

def deconstruct_keys(keys)
  { keyword_loc: keyword_loc, arguments: arguments, location: location }
end

#keywordObject

def keyword: () -> String



5473
5474
5475
# File 'lib/yarp/node.rb', line 5473

def keyword
  keyword_loc.slice
end