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.



9367
9368
9369
9370
9371
# File 'lib/syntax_tree.rb', line 9367

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



9365
9366
9367
# File 'lib/syntax_tree.rb', line 9365

def comments
  @comments
end

#locationObject (readonly)

Location

the location of this node



9362
9363
9364
# File 'lib/syntax_tree.rb', line 9362

def location
  @location
end

#valueObject (readonly)

String

the value of the keyword



9359
9360
9361
# File 'lib/syntax_tree.rb', line 9359

def value
  @value
end

Instance Method Details

#child_nodesObject



9373
9374
9375
# File 'lib/syntax_tree.rb', line 9373

def child_nodes
  []
end

#format(q) ⇒ Object



9377
9378
9379
# File 'lib/syntax_tree.rb', line 9377

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

#pretty_print(q) ⇒ Object



9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
# File 'lib/syntax_tree.rb', line 9381

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



9392
9393
9394
9395
9396
# File 'lib/syntax_tree.rb', line 9392

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