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.
9662
9663
9664
9665
9666
|
# File 'lib/syntax_tree/node.rb', line 9662
def initialize(arguments:, location:)
@arguments = arguments
@location = location
@comments = []
end
|
Instance Attribute Details
#arguments ⇒ Object
- nil | Args
-
the arguments being passed to the keyword
9657
9658
9659
|
# File 'lib/syntax_tree/node.rb', line 9657
def arguments
@arguments
end
|
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
9660
9661
9662
|
# File 'lib/syntax_tree/node.rb', line 9660
def
@comments
end
|
Instance Method Details
#===(other) ⇒ Object
9697
9698
9699
|
# File 'lib/syntax_tree/node.rb', line 9697
def ===(other)
other.is_a?(ReturnNode) && arguments === other.arguments
end
|
#accept(visitor) ⇒ Object
9668
9669
9670
|
# File 'lib/syntax_tree/node.rb', line 9668
def accept(visitor)
visitor.visit_return(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
9672
9673
9674
|
# File 'lib/syntax_tree/node.rb', line 9672
def child_nodes
[arguments]
end
|
#copy(arguments: nil, location: nil) ⇒ Object
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
|
# File 'lib/syntax_tree/node.rb', line 9676
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
9689
9690
9691
|
# File 'lib/syntax_tree/node.rb', line 9689
def deconstruct_keys(_keys)
{ arguments: arguments, location: location, comments: }
end
|