Class: SyntaxTree::Redo

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree.rb

Overview

Redo represents the use of the redo keyword.

redo

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value:, location:, comments: []) ⇒ Redo

Returns a new instance of Redo.



9800
9801
9802
9803
9804
# File 'lib/syntax_tree.rb', line 9800

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

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



9798
9799
9800
# File 'lib/syntax_tree.rb', line 9798

def comments
  @comments
end

#locationObject (readonly)

Location

the location of this node



9795
9796
9797
# File 'lib/syntax_tree.rb', line 9795

def location
  @location
end

#valueObject (readonly)

String

the value of the keyword



9792
9793
9794
# File 'lib/syntax_tree.rb', line 9792

def value
  @value
end

Instance Method Details

#child_nodesObject



9806
9807
9808
# File 'lib/syntax_tree.rb', line 9806

def child_nodes
  []
end

#format(q) ⇒ Object



9810
9811
9812
# File 'lib/syntax_tree.rb', line 9810

def format(q)
  q.text(value)
end

#pretty_print(q) ⇒ Object



9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
# File 'lib/syntax_tree.rb', line 9814

def pretty_print(q)
  q.group(2, "(", ")") do
    q.text("redo")

    q.breakable
    q.pp(value)

    q.pp(Comment::List.new(comments))
  end
end

#to_json(*opts) ⇒ Object



9825
9826
9827
9828
9829
# File 'lib/syntax_tree.rb', line 9825

def to_json(*opts)
  { type: :redo, value: value, loc: location, cmts: comments }.to_json(
    *opts
  )
end