Class: SyntaxTree::Redo
Overview
Redo represents the use of the redo keyword.
redo
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: []) ⇒ Redo
constructor
A new instance of Redo.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, location:, comments: []) ⇒ Redo
Returns a new instance of Redo.
8210 8211 8212 8213 8214 |
# File 'lib/syntax_tree/node.rb', line 8210 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
8208 8209 8210 |
# File 'lib/syntax_tree/node.rb', line 8208 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the value of the keyword
8205 8206 8207 |
# File 'lib/syntax_tree/node.rb', line 8205 def value @value end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
8216 8217 8218 |
# File 'lib/syntax_tree/node.rb', line 8216 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
8222 8223 8224 |
# File 'lib/syntax_tree/node.rb', line 8222 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
8226 8227 8228 |
# File 'lib/syntax_tree/node.rb', line 8226 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 |
# File 'lib/syntax_tree/node.rb', line 8230 def pretty_print(q) q.group(2, "(", ")") do q.text("redo") q.breakable q.pp(value) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
8241 8242 8243 8244 8245 |
# File 'lib/syntax_tree/node.rb', line 8241 def to_json(*opts) { type: :redo, value: value, loc: location, cmts: comments }.to_json( *opts ) end |