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

Returns a new instance of Redo.



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

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

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



8909
8910
8911
# File 'lib/syntax_tree/node.rb', line 8909

def comments
  @comments
end

Instance Method Details

#===(other) ⇒ Object



8941
8942
8943
# File 'lib/syntax_tree/node.rb', line 8941

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

#accept(visitor) ⇒ Object



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

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

#child_nodesObject Also known as: deconstruct



8920
8921
8922
# File 'lib/syntax_tree/node.rb', line 8920

def child_nodes
  []
end

#copy(location: nil) ⇒ Object



8924
8925
8926
8927
8928
8929
# File 'lib/syntax_tree/node.rb', line 8924

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

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

#deconstruct_keys(_keys) ⇒ Object



8933
8934
8935
# File 'lib/syntax_tree/node.rb', line 8933

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

#format(q) ⇒ Object



8937
8938
8939
# File 'lib/syntax_tree/node.rb', line 8937

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