Class: SyntaxTree::EmbDoc

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

Overview

EmbDoc represents a multi-line comment.

=begin
first line
second line
=end

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Constructor Details

#initialize(value:, location:) ⇒ EmbDoc

Returns a new instance of EmbDoc.



4656
4657
4658
4659
# File 'lib/syntax_tree/node.rb', line 4656

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

Instance Attribute Details

#valueObject (readonly)

String

the contents of the comment



4654
4655
4656
# File 'lib/syntax_tree/node.rb', line 4654

def value
  @value
end

Instance Method Details

#child_nodesObject Also known as: deconstruct



4673
4674
4675
# File 'lib/syntax_tree/node.rb', line 4673

def child_nodes
  []
end

#commentsObject



4669
4670
4671
# File 'lib/syntax_tree/node.rb', line 4669

def comments
  []
end

#deconstruct_keys(keys) ⇒ Object



4679
4680
4681
# File 'lib/syntax_tree/node.rb', line 4679

def deconstruct_keys(keys)
  { value: value, location: location }
end

#format(q) ⇒ Object



4683
4684
4685
4686
# File 'lib/syntax_tree/node.rb', line 4683

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

#ignore?Boolean

Returns:

  • (Boolean)


4665
4666
4667
# File 'lib/syntax_tree/node.rb', line 4665

def ignore?
  false
end

#inline?Boolean

Returns:

  • (Boolean)


4661
4662
4663
# File 'lib/syntax_tree/node.rb', line 4661

def inline?
  false
end

#pretty_print(q) ⇒ Object



4688
4689
4690
4691
4692
4693
4694
4695
# File 'lib/syntax_tree/node.rb', line 4688

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

    q.breakable
    q.pp(value)
  end
end

#to_json(*opts) ⇒ Object



4697
4698
4699
# File 'lib/syntax_tree/node.rb', line 4697

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