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[nil | Node].
-
#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? }.
-
#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.
-
#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.
14530 14531 14532 14533 14534 14535 14536 14537 |
# File 'lib/prism/node.rb', line 14530 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?
14582 14583 14584 |
# File 'lib/prism/node.rb', line 14582 def arguments @arguments end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
14600 14601 14602 |
# File 'lib/prism/node.rb', line 14600 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.
14606 14607 14608 14609 14610 |
# File 'lib/prism/node.rb', line 14606 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
14540 14541 14542 |
# File 'lib/prism/node.rb', line 14540 def accept(visitor) visitor.visit_return_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
14545 14546 14547 |
# File 'lib/prism/node.rb', line 14545 def child_nodes [arguments] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
14557 14558 14559 |
# File 'lib/prism/node.rb', line 14557 def comment_targets [keyword_loc, *arguments] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
14550 14551 14552 14553 14554 |
# File 'lib/prism/node.rb', line 14550 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
14562 14563 14564 |
# File 'lib/prism/node.rb', line 14562 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? }
14570 14571 14572 |
# File 'lib/prism/node.rb', line 14570 def deconstruct_keys(keys) { node_id: node_id, location: location, keyword_loc: keyword_loc, arguments: arguments } end |
#inspect ⇒ Object
def inspect -> String
14590 14591 14592 |
# File 'lib/prism/node.rb', line 14590 def inspect InspectVisitor.compose(self) end |
#keyword ⇒ Object
def keyword: () -> String
14585 14586 14587 |
# File 'lib/prism/node.rb', line 14585 def keyword keyword_loc.slice end |
#keyword_loc ⇒ Object
attr_reader keyword_loc: Location
14575 14576 14577 14578 14579 |
# File 'lib/prism/node.rb', line 14575 def keyword_loc location = @keyword_loc return location if location.is_a?(Location) @keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
14595 14596 14597 |
# File 'lib/prism/node.rb', line 14595 def type :return_node end |