Class: SyntaxTree::Return0
- Inherits:
-
Object
- Object
- SyntaxTree::Return0
- Defined in:
- lib/syntax_tree.rb
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
- #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.
10582 10583 10584 10585 10586 |
# File 'lib/syntax_tree.rb', line 10582 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
10580 10581 10582 |
# File 'lib/syntax_tree.rb', line 10580 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
10577 10578 10579 |
# File 'lib/syntax_tree.rb', line 10577 def location @location end |
#value ⇒ Object (readonly)
- String
-
the value of the keyword
10574 10575 10576 |
# File 'lib/syntax_tree.rb', line 10574 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
10588 10589 10590 |
# File 'lib/syntax_tree.rb', line 10588 def child_nodes [] end |
#format(q) ⇒ Object
10592 10593 10594 |
# File 'lib/syntax_tree.rb', line 10592 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 |
# File 'lib/syntax_tree.rb', line 10596 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
10607 10608 10609 10610 10611 |
# File 'lib/syntax_tree.rb', line 10607 def to_json(*opts) { type: :return0, value: value, loc: location, cmts: comments }.to_json( *opts ) end |