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.



8976
8977
8978
8979
# File 'lib/syntax_tree/node.rb', line 8976

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

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



8974
8975
8976
# File 'lib/syntax_tree/node.rb', line 8974

def comments
  @comments
end

Instance Method Details

#===(other) ⇒ Object



9006
9007
9008
# File 'lib/syntax_tree/node.rb', line 9006

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

#accept(visitor) ⇒ Object



8981
8982
8983
# File 'lib/syntax_tree/node.rb', line 8981

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

#child_nodesObject Also known as: deconstruct



8985
8986
8987
# File 'lib/syntax_tree/node.rb', line 8985

def child_nodes
  []
end

#copy(location: nil) ⇒ Object



8989
8990
8991
8992
8993
8994
# File 'lib/syntax_tree/node.rb', line 8989

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

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

#deconstruct_keys(_keys) ⇒ Object



8998
8999
9000
# File 'lib/syntax_tree/node.rb', line 8998

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

#format(q) ⇒ Object



9002
9003
9004
# File 'lib/syntax_tree/node.rb', line 9002

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