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.



5615
5616
5617
5618
# File 'lib/syntax_tree.rb', line 5615

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

Instance Attribute Details

#locationObject (readonly)

Location

the location of this node



5613
5614
5615
# File 'lib/syntax_tree.rb', line 5613

def location
  @location
end

#valueObject (readonly)

String

the contents of the comment



5610
5611
5612
# File 'lib/syntax_tree.rb', line 5610

def value
  @value
end

Instance Method Details

#child_nodesObject



5632
5633
5634
# File 'lib/syntax_tree.rb', line 5632

def child_nodes
  []
end

#commentsObject



5628
5629
5630
# File 'lib/syntax_tree.rb', line 5628

def comments
  []
end

#format(q) ⇒ Object



5636
5637
5638
5639
# File 'lib/syntax_tree.rb', line 5636

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

#ignore?Boolean

Returns:

  • (Boolean)


5624
5625
5626
# File 'lib/syntax_tree.rb', line 5624

def ignore?
  false
end

#inline?Boolean

Returns:

  • (Boolean)


5620
5621
5622
# File 'lib/syntax_tree.rb', line 5620

def inline?
  false
end

#pretty_print(q) ⇒ Object



5641
5642
5643
5644
5645
5646
5647
5648
# File 'lib/syntax_tree.rb', line 5641

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

    q.breakable
    q.pp(value)
  end
end

#to_json(*opts) ⇒ Object



5650
5651
5652
# File 'lib/syntax_tree.rb', line 5650

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