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
10071 10072 10073 10074 10075 |
# File 'lib/syntax_tree.rb', line 10071 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
10063 10064 10065 |
# File 'lib/syntax_tree.rb', line 10063 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
10069 10070 10071 |
# File 'lib/syntax_tree.rb', line 10069 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
10066 10067 10068 |
# File 'lib/syntax_tree.rb', line 10066 def location @location end |
Instance Method Details
#child_nodes ⇒ Object
10077 10078 10079 |
# File 'lib/syntax_tree.rb', line 10077 def child_nodes [arguments] end |
#format(q) ⇒ Object
10081 10082 10083 |
# File 'lib/syntax_tree.rb', line 10081 def format(q) FlowControlFormatter.new("return", self).format(q) end |
#pretty_print(q) ⇒ Object
10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 |
# File 'lib/syntax_tree.rb', line 10085 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
10096 10097 10098 10099 10100 |
# File 'lib/syntax_tree.rb', line 10096 def to_json(*opts) { type: :return, args: arguments, loc: location, cmts: comments }.to_json( *opts ) end |