Class: SyntaxTree::Return0
Overview
Return0 represents the bare return keyword with no arguments.
return
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
-
#value ⇒ Object
readonly
- String
-
the value of the keyword.
Instance Method Summary collapse
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ Return0
constructor
A new instance of Return0.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, location:, comments: []) ⇒ Return0
Returns a new instance of Return0.
9213 9214 9215 9216 9217 |
# File 'lib/syntax_tree/node.rb', line 9213 def initialize(value:, location:, comments: []) @value = value @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
9211 9212 9213 |
# File 'lib/syntax_tree/node.rb', line 9211 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
9208 9209 9210 |
# File 'lib/syntax_tree/node.rb', line 9208 def location @location end |
#value ⇒ Object (readonly)
- String
-
the value of the keyword
9205 9206 9207 |
# File 'lib/syntax_tree/node.rb', line 9205 def value @value end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
9219 9220 9221 |
# File 'lib/syntax_tree/node.rb', line 9219 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
9225 9226 9227 |
# File 'lib/syntax_tree/node.rb', line 9225 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
9229 9230 9231 |
# File 'lib/syntax_tree/node.rb', line 9229 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 |
# File 'lib/syntax_tree/node.rb', line 9233 def pretty_print(q) q.group(2, "(", ")") do q.text("return0") q.breakable q.pp(value) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
9244 9245 9246 9247 9248 |
# File 'lib/syntax_tree/node.rb', line 9244 def to_json(*opts) { type: :return0, value: value, loc: location, cmts: comments }.to_json( *opts ) end |