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, #pretty_print, #to_json
Constructor Details
#initialize(arguments:, location:) ⇒ ReturnNode
Returns a new instance of ReturnNode.
9562
9563
9564
9565
9566
|
# File 'lib/syntax_tree/node.rb', line 9562
def initialize(arguments:, location:)
@arguments = arguments
@location = location
@comments = []
end
|
Instance Attribute Details
#arguments ⇒ Object
- nil | Args
-
the arguments being passed to the keyword
9557
9558
9559
|
# File 'lib/syntax_tree/node.rb', line 9557
def arguments
@arguments
end
|
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
9560
9561
9562
|
# File 'lib/syntax_tree/node.rb', line 9560
def
@comments
end
|
Instance Method Details
#===(other) ⇒ Object
9597
9598
9599
|
# File 'lib/syntax_tree/node.rb', line 9597
def ===(other)
other.is_a?(ReturnNode) && arguments === other.arguments
end
|
#accept(visitor) ⇒ Object
9568
9569
9570
|
# File 'lib/syntax_tree/node.rb', line 9568
def accept(visitor)
visitor.visit_return(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
9572
9573
9574
|
# File 'lib/syntax_tree/node.rb', line 9572
def child_nodes
[arguments]
end
|
#copy(arguments: nil, location: nil) ⇒ Object
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
|
# File 'lib/syntax_tree/node.rb', line 9576
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
9589
9590
9591
|
# File 'lib/syntax_tree/node.rb', line 9589
def deconstruct_keys(_keys)
{ arguments: arguments, location: location, comments: }
end
|