class YARP::ReturnNode
Represents the use of the ‘return` keyword.
return 1 ^^^^^^^^
Attributes
arguments[R]
attr_reader arguments: ArgumentsNode
?
keyword_loc[R]
attr_reader keyword_loc
: Location
Public Class Methods
new(keyword_loc, arguments, location)
click to toggle source
def initialize: (keyword_loc
: Location, arguments: ArgumentsNode
?, location: Location) -> void
# File lib/yarp/node.rb, line 10284 def initialize(keyword_loc, arguments, location) @keyword_loc = keyword_loc @arguments = arguments @location = location end
Public Instance Methods
accept(visitor)
click to toggle source
def accept: (visitor: Visitor
) -> void
# File lib/yarp/node.rb, line 10291 def accept(visitor) visitor.visit_return_node(self) end
child_nodes()
click to toggle source
def child_nodes
: () -> Array[nil | Node]
# File lib/yarp/node.rb, line 10296 def child_nodes [arguments] end
Also aliased as: deconstruct
comment_targets()
click to toggle source
def comment_targets
: () -> Array[Node | Location]
# File lib/yarp/node.rb, line 10308 def comment_targets [keyword_loc, *arguments] end
compact_child_nodes()
click to toggle source
def compact_child_nodes
: () -> Array
# File lib/yarp/node.rb, line 10301 def compact_child_nodes compact = [] compact << arguments if arguments compact end
copy(**params)
click to toggle source
def copy: (**params) -> ReturnNode
# File lib/yarp/node.rb, line 10313 def copy(**params) ReturnNode.new( params.fetch(:keyword_loc) { keyword_loc }, params.fetch(:arguments) { arguments }, params.fetch(:location) { location }, ) end
deconstruct_keys(keys)
click to toggle source
def deconstruct_keys
: (keys: Array) -> Hash[Symbol, nil | Node | Array | String
| Token | Array | Location]
# File lib/yarp/node.rb, line 10325 def deconstruct_keys(keys) { keyword_loc: keyword_loc, arguments: arguments, location: location } end
inspect(inspector = NodeInspector.new)
click to toggle source
# File lib/yarp/node.rb, line 10334 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) inspector << "├── keyword_loc: #{inspector.location(keyword_loc)}\n" if (arguments = self.arguments).nil? inspector << "└── arguments: ∅\n" else inspector << "└── arguments:\n" inspector << arguments.inspect(inspector.child_inspector(" ")).delete_prefix(inspector.prefix) end inspector.to_str end
keyword()
click to toggle source
def keyword: () -> String
# File lib/yarp/node.rb, line 10330 def keyword keyword_loc.slice end