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.
13913 13914 13915 13916 13917 |
# File 'lib/syntax_tree.rb', line 13913 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
13911 13912 13913 |
# File 'lib/syntax_tree.rb', line 13911 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
13908 13909 13910 |
# File 'lib/syntax_tree.rb', line 13908 def location @location end |
#value ⇒ Object (readonly)
- String
-
the value of the keyword
13905 13906 13907 |
# File 'lib/syntax_tree.rb', line 13905 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
13919 13920 13921 |
# File 'lib/syntax_tree.rb', line 13919 def child_nodes [] end |
#format(q) ⇒ Object
13923 13924 13925 |
# File 'lib/syntax_tree.rb', line 13923 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
13927 13928 13929 13930 13931 13932 13933 13934 13935 13936 |
# File 'lib/syntax_tree.rb', line 13927 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
13938 13939 13940 13941 13942 |
# File 'lib/syntax_tree.rb', line 13938 def to_json(*opts) { type: :yield0, value: value, loc: location, cmts: comments }.to_json( *opts ) end |