Class: SyntaxTree::Retry
Overview
Retry represents the use of the retry keyword.
retry
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: []) ⇒ Retry
constructor
A new instance of Retry.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, location:, comments: []) ⇒ Retry
Returns a new instance of Retry.
8773 8774 8775 8776 8777 |
# File 'lib/syntax_tree/node.rb', line 8773 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
8771 8772 8773 |
# File 'lib/syntax_tree/node.rb', line 8771 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the value of the keyword
8768 8769 8770 |
# File 'lib/syntax_tree/node.rb', line 8768 def value @value end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
8779 8780 8781 |
# File 'lib/syntax_tree/node.rb', line 8779 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
8785 8786 8787 |
# File 'lib/syntax_tree/node.rb', line 8785 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
8789 8790 8791 |
# File 'lib/syntax_tree/node.rb', line 8789 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 |
# File 'lib/syntax_tree/node.rb', line 8793 def pretty_print(q) q.group(2, "(", ")") do q.text("retry") q.breakable q.pp(value) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
8804 8805 8806 8807 8808 |
# File 'lib/syntax_tree/node.rb', line 8804 def to_json(*opts) { type: :retry, value: value, loc: location, cmts: comments }.to_json( *opts ) end |