Class: SyntaxTree::Return
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.
Attributes inherited from Node
Instance Method Summary collapse
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ 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.
8822 8823 8824 8825 8826 |
# File 'lib/syntax_tree/node.rb', line 8822 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
8817 8818 8819 |
# File 'lib/syntax_tree/node.rb', line 8817 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8820 8821 8822 |
# File 'lib/syntax_tree/node.rb', line 8820 def comments @comments end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
8828 8829 8830 |
# File 'lib/syntax_tree/node.rb', line 8828 def child_nodes [arguments] end |
#deconstruct_keys(keys) ⇒ Object
8834 8835 8836 |
# File 'lib/syntax_tree/node.rb', line 8834 def deconstruct_keys(keys) { arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
8838 8839 8840 |
# File 'lib/syntax_tree/node.rb', line 8838 def format(q) FlowControlFormatter.new("return", self).format(q) end |
#pretty_print(q) ⇒ Object
8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 |
# File 'lib/syntax_tree/node.rb', line 8842 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
8853 8854 8855 8856 8857 |
# File 'lib/syntax_tree/node.rb', line 8853 def to_json(*opts) { type: :return, args: arguments, loc: location, cmts: comments }.to_json( *opts ) end |