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.



8876
8877
8878
8879
# File 'lib/syntax_tree/node.rb', line 8876

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

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



8874
8875
8876
# File 'lib/syntax_tree/node.rb', line 8874

def comments
  @comments
end

Instance Method Details

#===(other) ⇒ Object



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

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

#accept(visitor) ⇒ Object



8881
8882
8883
# File 'lib/syntax_tree/node.rb', line 8881

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

#child_nodesObject Also known as: deconstruct



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

def child_nodes
  []
end

#copy(location: nil) ⇒ Object



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

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

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

#deconstruct_keys(_keys) ⇒ Object



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

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

#format(q) ⇒ Object



8902
8903
8904
# File 'lib/syntax_tree/node.rb', line 8902

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