Class: SyntaxTree::ReturnNode
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::ReturnNode
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
Return represents using the return
keyword with arguments.
return value
Instance Attribute Summary collapse
Attributes inherited from Node
#location
Instance Method Summary
collapse
Methods inherited from Node
#construct_keys, #end_char, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(arguments:, location:) ⇒ ReturnNode
Returns a new instance of ReturnNode.
9710
9711
9712
9713
9714
|
# File 'lib/syntax_tree/node.rb', line 9710
def initialize(arguments:, location:)
@arguments = arguments
@location = location
@comments = []
end
|
Instance Attribute Details
#arguments ⇒ Object
- nil | Args
-
the arguments being passed to the keyword
9705
9706
9707
|
# File 'lib/syntax_tree/node.rb', line 9705
def arguments
@arguments
end
|
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
9708
9709
9710
|
# File 'lib/syntax_tree/node.rb', line 9708
def
@comments
end
|
Instance Method Details
#===(other) ⇒ Object
9745
9746
9747
|
# File 'lib/syntax_tree/node.rb', line 9745
def ===(other)
other.is_a?(ReturnNode) && arguments === other.arguments
end
|
#accept(visitor) ⇒ Object
9716
9717
9718
|
# File 'lib/syntax_tree/node.rb', line 9716
def accept(visitor)
visitor.visit_return(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
9720
9721
9722
|
# File 'lib/syntax_tree/node.rb', line 9720
def child_nodes
[arguments]
end
|
#copy(arguments: nil, location: nil) ⇒ Object
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
|
# File 'lib/syntax_tree/node.rb', line 9724
def copy(arguments: nil, location: nil)
node =
ReturnNode.new(
arguments: arguments || self.arguments,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
9737
9738
9739
|
# File 'lib/syntax_tree/node.rb', line 9737
def deconstruct_keys(_keys)
{ arguments: arguments, location: location, comments: }
end
|