Class: SyntaxTree::Yield0
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.
-
#value ⇒ Object
readonly
- String
-
the value of the keyword.
Attributes inherited from Node
Instance Method Summary collapse
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ 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.
11419 11420 11421 11422 11423 |
# File 'lib/syntax_tree/node.rb', line 11419 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
11417 11418 11419 |
# File 'lib/syntax_tree/node.rb', line 11417 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the value of the keyword
11414 11415 11416 |
# File 'lib/syntax_tree/node.rb', line 11414 def value @value end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
11425 11426 11427 |
# File 'lib/syntax_tree/node.rb', line 11425 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
11431 11432 11433 |
# File 'lib/syntax_tree/node.rb', line 11431 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
11435 11436 11437 |
# File 'lib/syntax_tree/node.rb', line 11435 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 |
# File 'lib/syntax_tree/node.rb', line 11439 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
11450 11451 11452 11453 11454 |
# File 'lib/syntax_tree/node.rb', line 11450 def to_json(*opts) { type: :yield0, value: value, loc: location, cmts: comments }.to_json( *opts ) end |