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.



9040
9041
9042
9043
# File 'lib/syntax_tree/node.rb', line 9040

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

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



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

def comments
  @comments
end

Instance Method Details

#===(other) ⇒ Object



9070
9071
9072
# File 'lib/syntax_tree/node.rb', line 9070

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

#accept(visitor) ⇒ Object



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

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

#child_nodesObject Also known as: deconstruct



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

def child_nodes
  []
end

#copy(location: nil) ⇒ Object



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

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

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

#deconstruct_keys(_keys) ⇒ Object



9062
9063
9064
# File 'lib/syntax_tree/node.rb', line 9062

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

#format(q) ⇒ Object



9066
9067
9068
# File 'lib/syntax_tree/node.rb', line 9066

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