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.



9876
9877
9878
9879
9880
# File 'lib/syntax_tree.rb', line 9876

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



9874
9875
9876
# File 'lib/syntax_tree.rb', line 9874

def comments
  @comments
end

#locationObject (readonly)

Location

the location of this node



9871
9872
9873
# File 'lib/syntax_tree.rb', line 9871

def location
  @location
end

#valueObject (readonly)

String

the value of the keyword



9868
9869
9870
# File 'lib/syntax_tree.rb', line 9868

def value
  @value
end

Instance Method Details

#child_nodesObject



9882
9883
9884
# File 'lib/syntax_tree.rb', line 9882

def child_nodes
  []
end

#format(q) ⇒ Object



9886
9887
9888
# File 'lib/syntax_tree.rb', line 9886

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

#pretty_print(q) ⇒ Object



9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
# File 'lib/syntax_tree.rb', line 9890

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



9901
9902
9903
9904
9905
# File 'lib/syntax_tree.rb', line 9901

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