Class: SyntaxTree::Redo

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

Overview

Redo represents the use of the redo keyword.

redo

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#construct_keys, #end_char, #pretty_print, #start_char, #to_json, #to_mermaid

Constructor Details

#initialize(location:) ⇒ Redo

Returns a new instance of Redo.



9024
9025
9026
9027
# File 'lib/syntax_tree/node.rb', line 9024

def initialize(location:)
  @location = location
  @comments = []
end

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



9022
9023
9024
# File 'lib/syntax_tree/node.rb', line 9022

def comments
  @comments
end

Instance Method Details

#===(other) ⇒ Object



9054
9055
9056
# File 'lib/syntax_tree/node.rb', line 9054

def ===(other)
  other.is_a?(Redo)
end

#accept(visitor) ⇒ Object



9029
9030
9031
# File 'lib/syntax_tree/node.rb', line 9029

def accept(visitor)
  visitor.visit_redo(self)
end

#child_nodesObject Also known as: deconstruct



9033
9034
9035
# File 'lib/syntax_tree/node.rb', line 9033

def child_nodes
  []
end

#copy(location: nil) ⇒ Object



9037
9038
9039
9040
9041
9042
# File 'lib/syntax_tree/node.rb', line 9037

def copy(location: nil)
  node = Redo.new(location: location || self.location)

  node.comments.concat(comments.map(&:copy))
  node
end

#deconstruct_keys(_keys) ⇒ Object



9046
9047
9048
# File 'lib/syntax_tree/node.rb', line 9046

def deconstruct_keys(_keys)
  { location: location, comments: comments }
end

#format(q) ⇒ Object



9050
9051
9052
# File 'lib/syntax_tree/node.rb', line 9050

def format(q)
  q.text("redo")
end