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.
13709 13710 13711 13712 13713 |
# File 'lib/syntax_tree.rb', line 13709 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
13707 13708 13709 |
# File 'lib/syntax_tree.rb', line 13707 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
13704 13705 13706 |
# File 'lib/syntax_tree.rb', line 13704 def location @location end |
#value ⇒ Object (readonly)
- String
-
the value of the keyword
13701 13702 13703 |
# File 'lib/syntax_tree.rb', line 13701 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
13715 13716 13717 |
# File 'lib/syntax_tree.rb', line 13715 def child_nodes [] end |
#format(q) ⇒ Object
13719 13720 13721 |
# File 'lib/syntax_tree.rb', line 13719 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
13723 13724 13725 13726 13727 13728 13729 13730 13731 13732 |
# File 'lib/syntax_tree.rb', line 13723 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
13734 13735 13736 13737 13738 |
# File 'lib/syntax_tree.rb', line 13734 def to_json(*opts) { type: :yield0, value: value, loc: location, cmts: comments }.to_json( *opts ) end |