Class: Prism::ReturnNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::ReturnNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents the use of the return keyword.
return 1
^^^^^^^^
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
attr_reader arguments: ArgumentsNode?.
Class Method Summary collapse
-
.type ⇒ Object
Return a symbol representation of this node type.
Instance Method Summary collapse
-
#===(other) ⇒ Object
Implements case-equality for the node.
-
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array.
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, keyword_loc: self.keyword_loc, arguments: self.arguments) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?arguments: ArgumentsNode?) -> ReturnNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, keyword_loc: Location, arguments: ArgumentsNode? }.
-
#each_child_node {|arguments| ... } ⇒ Object
def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator.
-
#initialize(source, node_id, location, flags, keyword_loc, arguments) ⇒ ReturnNode
constructor
Initialize a new ReturnNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#keyword ⇒ Object
def keyword: () -> String.
-
#keyword_loc ⇒ Object
attr_reader keyword_loc: Location.
-
#save_keyword_loc(repository) ⇒ Object
Save the keyword_loc location using the given saved source so that it can be retrieved later.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, keyword_loc, arguments) ⇒ ReturnNode
Initialize a new ReturnNode node.
17253 17254 17255 17256 17257 17258 17259 17260 |
# File 'lib/prism/node.rb', line 17253 def initialize(source, node_id, location, flags, keyword_loc, arguments) @source = source @node_id = node_id @location = location @flags = flags @keyword_loc = keyword_loc @arguments = arguments end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
attr_reader arguments: ArgumentsNode?
17318 17319 17320 |
# File 'lib/prism/node.rb', line 17318 def arguments @arguments end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See Node::type.
17336 17337 17338 |
# File 'lib/prism/node.rb', line 17336 def self.type :return_node end |
Instance Method Details
#===(other) ⇒ Object
Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.
17342 17343 17344 17345 17346 |
# File 'lib/prism/node.rb', line 17342 def ===(other) other.is_a?(ReturnNode) && (keyword_loc.nil? == other.keyword_loc.nil?) && (arguments === other.arguments) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
17263 17264 17265 |
# File 'lib/prism/node.rb', line 17263 def accept(visitor) visitor.visit_return_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
17268 17269 17270 |
# File 'lib/prism/node.rb', line 17268 def child_nodes [arguments] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
17287 17288 17289 |
# File 'lib/prism/node.rb', line 17287 def comment_targets [keyword_loc, *arguments] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
17280 17281 17282 17283 17284 |
# File 'lib/prism/node.rb', line 17280 def compact_child_nodes compact = [] #: Array[Prism::node] compact << arguments if arguments compact end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, keyword_loc: self.keyword_loc, arguments: self.arguments) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?arguments: ArgumentsNode?) -> ReturnNode
17292 17293 17294 |
# File 'lib/prism/node.rb', line 17292 def copy(node_id: self.node_id, location: self.location, flags: self.flags, keyword_loc: self.keyword_loc, arguments: self.arguments) ReturnNode.new(source, node_id, location, flags, keyword_loc, arguments) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, keyword_loc: Location, arguments: ArgumentsNode? }
17300 17301 17302 |
# File 'lib/prism/node.rb', line 17300 def deconstruct_keys(keys) { node_id: node_id, location: location, keyword_loc: keyword_loc, arguments: arguments } end |
#each_child_node {|arguments| ... } ⇒ Object
def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator
17273 17274 17275 17276 17277 |
# File 'lib/prism/node.rb', line 17273 def each_child_node return to_enum(:each_child_node) unless block_given? yield arguments if arguments end |
#inspect ⇒ Object
def inspect -> String
17326 17327 17328 |
# File 'lib/prism/node.rb', line 17326 def inspect InspectVisitor.compose(self) end |
#keyword ⇒ Object
def keyword: () -> String
17321 17322 17323 |
# File 'lib/prism/node.rb', line 17321 def keyword keyword_loc.slice end |
#keyword_loc ⇒ Object
attr_reader keyword_loc: Location
17305 17306 17307 17308 17309 |
# File 'lib/prism/node.rb', line 17305 def keyword_loc location = @keyword_loc return location if location.is_a?(Location) @keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#save_keyword_loc(repository) ⇒ Object
Save the keyword_loc location using the given saved source so that it can be retrieved later.
17313 17314 17315 |
# File 'lib/prism/node.rb', line 17313 def save_keyword_loc(repository) repository.enter(node_id, :keyword_loc) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
17331 17332 17333 |
# File 'lib/prism/node.rb', line 17331 def type :return_node end |