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



5397
5398
5399
5400
5401
# File 'lib/yarp/node.rb', line 5397

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

Instance Attribute Details

#argumentsObject (readonly)

attr_reader arguments: Node?



5394
5395
5396
# File 'lib/yarp/node.rb', line 5394

def arguments
  @arguments
end

#keyword_locObject (readonly)

attr_reader keyword_loc: Location



5391
5392
5393
# File 'lib/yarp/node.rb', line 5391

def keyword_loc
  @keyword_loc
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



5404
5405
5406
# File 'lib/yarp/node.rb', line 5404

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

#child_nodesObject Also known as: deconstruct

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



5410
5411
5412
# File 'lib/yarp/node.rb', line 5410

def child_nodes
  [arguments]
end

#deconstruct_keys(keys) ⇒ Object

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



5418
5419
5420
# File 'lib/yarp/node.rb', line 5418

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

#keywordObject

def keyword: () -> String



5423
5424
5425
# File 'lib/yarp/node.rb', line 5423

def keyword
  keyword_loc.slice
end