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, #pretty_print, #to_json

Constructor Details

#initialize(location:) ⇒ Redo



8885
8886
8887
8888
# File 'lib/syntax_tree/node.rb', line 8885

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

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



8883
8884
8885
# File 'lib/syntax_tree/node.rb', line 8883

def comments
  @comments
end

Instance Method Details

#===(other) ⇒ Object



8915
8916
8917
# File 'lib/syntax_tree/node.rb', line 8915

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

#accept(visitor) ⇒ Object



8890
8891
8892
# File 'lib/syntax_tree/node.rb', line 8890

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

#child_nodesObject Also known as: deconstruct



8894
8895
8896
# File 'lib/syntax_tree/node.rb', line 8894

def child_nodes
  []
end

#copy(location: nil) ⇒ Object



8898
8899
8900
8901
8902
8903
# File 'lib/syntax_tree/node.rb', line 8898

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

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

#deconstruct_keys(_keys) ⇒ Object



8907
8908
8909
# File 'lib/syntax_tree/node.rb', line 8907

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

#format(q) ⇒ Object



8911
8912
8913
# File 'lib/syntax_tree/node.rb', line 8911

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