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.
10790 10791 10792 10793 10794 |
# File 'lib/syntax_tree.rb', line 10790 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
10788 10789 10790 |
# File 'lib/syntax_tree.rb', line 10788 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
10785 10786 10787 |
# File 'lib/syntax_tree.rb', line 10785 def location @location end |
#value ⇒ Object (readonly)
- String
-
the value of the keyword
10782 10783 10784 |
# File 'lib/syntax_tree.rb', line 10782 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
10796 10797 10798 |
# File 'lib/syntax_tree.rb', line 10796 def child_nodes [] end |
#format(q) ⇒ Object
10800 10801 10802 |
# File 'lib/syntax_tree.rb', line 10800 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 |
# File 'lib/syntax_tree.rb', line 10804 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
10815 10816 10817 10818 10819 |
# File 'lib/syntax_tree.rb', line 10815 def to_json(*opts) { type: :return0, value: value, loc: location, cmts: comments }.to_json( *opts ) end |