Class: SyntaxTree::Retry

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/node.rb

Overview

Retry represents the use of the retry keyword.

retry

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

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

#commentsObject (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

#valueObject (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_nodesObject 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