Class: SyntaxTree::Retry

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

Overview

Retry represents the use of the retry keyword.

retry

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value:, location:, comments: []) ⇒ Retry

Returns a new instance of Retry.



10017
10018
10019
10020
10021
# File 'lib/syntax_tree.rb', line 10017

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



10015
10016
10017
# File 'lib/syntax_tree.rb', line 10015

def comments
  @comments
end

#locationObject (readonly)

Location

the location of this node



10012
10013
10014
# File 'lib/syntax_tree.rb', line 10012

def location
  @location
end

#valueObject (readonly)

String

the value of the keyword



10009
10010
10011
# File 'lib/syntax_tree.rb', line 10009

def value
  @value
end

Instance Method Details

#child_nodesObject



10023
10024
10025
# File 'lib/syntax_tree.rb', line 10023

def child_nodes
  []
end

#format(q) ⇒ Object



10027
10028
10029
# File 'lib/syntax_tree.rb', line 10027

def format(q)
  q.text(value)
end

#pretty_print(q) ⇒ Object



10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
# File 'lib/syntax_tree.rb', line 10031

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



10042
10043
10044
10045
10046
# File 'lib/syntax_tree.rb', line 10042

def to_json(*opts)
  { type: :retry, value: value, loc: location, cmts: comments }.to_json(
    *opts
  )
end