Class: SyntaxTree::Yield0
- Inherits:
-
Object
- Object
- SyntaxTree::Yield0
- Defined in:
- lib/syntax_tree.rb
Overview
Yield0 represents the bare yield keyword with no arguments.
yield
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: []) ⇒ Yield0
constructor
A new instance of Yield0.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, location:, comments: []) ⇒ Yield0
Returns a new instance of Yield0.
13618 13619 13620 13621 13622 |
# File 'lib/syntax_tree.rb', line 13618 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
13616 13617 13618 |
# File 'lib/syntax_tree.rb', line 13616 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
13613 13614 13615 |
# File 'lib/syntax_tree.rb', line 13613 def location @location end |
#value ⇒ Object (readonly)
- String
-
the value of the keyword
13610 13611 13612 |
# File 'lib/syntax_tree.rb', line 13610 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
13624 13625 13626 |
# File 'lib/syntax_tree.rb', line 13624 def child_nodes [] end |
#format(q) ⇒ Object
13628 13629 13630 |
# File 'lib/syntax_tree.rb', line 13628 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 |
# File 'lib/syntax_tree.rb', line 13632 def pretty_print(q) q.group(2, "(", ")") do q.text("yield0") q.breakable q.pp(value) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
13643 13644 13645 13646 13647 |
# File 'lib/syntax_tree.rb', line 13643 def to_json(*opts) { type: :yield0, value: value, loc: location, cmts: comments }.to_json( *opts ) end |