Class: SyntaxTree::EmbDoc

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

Overview

EmbDoc represents a multi-line comment.

=begin
first line
second line
=end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value:, location:) ⇒ EmbDoc

Returns a new instance of EmbDoc.



5483
5484
5485
5486
# File 'lib/syntax_tree.rb', line 5483

def initialize(value:, location:)
  @value = value
  @location = location
end

Instance Attribute Details

#locationObject (readonly)

Location

the location of this node



5481
5482
5483
# File 'lib/syntax_tree.rb', line 5481

def location
  @location
end

#valueObject (readonly)

String

the contents of the comment



5478
5479
5480
# File 'lib/syntax_tree.rb', line 5478

def value
  @value
end

Instance Method Details

#child_nodesObject



5500
5501
5502
# File 'lib/syntax_tree.rb', line 5500

def child_nodes
  []
end

#commentsObject



5496
5497
5498
# File 'lib/syntax_tree.rb', line 5496

def comments
  []
end

#format(q) ⇒ Object



5504
5505
5506
5507
# File 'lib/syntax_tree.rb', line 5504

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

#ignore?Boolean

Returns:

  • (Boolean)


5492
5493
5494
# File 'lib/syntax_tree.rb', line 5492

def ignore?
  false
end

#inline?Boolean

Returns:

  • (Boolean)


5488
5489
5490
# File 'lib/syntax_tree.rb', line 5488

def inline?
  false
end

#pretty_print(q) ⇒ Object



5509
5510
5511
5512
5513
5514
5515
5516
# File 'lib/syntax_tree.rb', line 5509

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

    q.breakable
    q.pp(value)
  end
end

#to_json(*opts) ⇒ Object



5518
5519
5520
# File 'lib/syntax_tree.rb', line 5518

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