Class: SyntaxTree::Return
- Inherits:
-
Object
- Object
- SyntaxTree::Return
- Defined in:
- lib/syntax_tree.rb
Overview
Return represents using the return
keyword with arguments.
return value
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
- Args
-
the arguments being passed to the keyword.
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(arguments:, location:, comments: []) ⇒ Return
constructor
A new instance of Return.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(arguments:, location:, comments: []) ⇒ Return
Returns a new instance of Return.
10601 10602 10603 10604 10605 |
# File 'lib/syntax_tree.rb', line 10601 def initialize(arguments:, location:, comments: []) @arguments = arguments @location = location @comments = comments end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
- Args
-
the arguments being passed to the keyword
10593 10594 10595 |
# File 'lib/syntax_tree.rb', line 10593 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
10599 10600 10601 |
# File 'lib/syntax_tree.rb', line 10599 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
10596 10597 10598 |
# File 'lib/syntax_tree.rb', line 10596 def location @location end |
Instance Method Details
#child_nodes ⇒ Object
10607 10608 10609 |
# File 'lib/syntax_tree.rb', line 10607 def child_nodes [arguments] end |
#format(q) ⇒ Object
10611 10612 10613 |
# File 'lib/syntax_tree.rb', line 10611 def format(q) FlowControlFormatter.new("return", self).format(q) end |
#pretty_print(q) ⇒ Object
10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 |
# File 'lib/syntax_tree.rb', line 10615 def pretty_print(q) q.group(2, "(", ")") do q.text("return") q.breakable q.pp(arguments) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
10626 10627 10628 10629 10630 |
# File 'lib/syntax_tree.rb', line 10626 def to_json(*opts) { type: :return, args: arguments, loc: location, cmts: comments }.to_json( *opts ) end |