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

Instance Method Summary collapse

Constructor Details

#initialize(value:, location:) ⇒ EmbDoc

Returns a new instance of EmbDoc.



4809
4810
4811
4812
# File 'lib/syntax_tree/node.rb', line 4809

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

Instance Attribute Details

#locationObject (readonly)

Location

the location of this node



4807
4808
4809
# File 'lib/syntax_tree/node.rb', line 4807

def location
  @location
end

#valueObject (readonly)

String

the contents of the comment



4804
4805
4806
# File 'lib/syntax_tree/node.rb', line 4804

def value
  @value
end

Instance Method Details

#child_nodesObject Also known as: deconstruct



4826
4827
4828
# File 'lib/syntax_tree/node.rb', line 4826

def child_nodes
  []
end

#commentsObject



4822
4823
4824
# File 'lib/syntax_tree/node.rb', line 4822

def comments
  []
end

#deconstruct_keys(keys) ⇒ Object



4832
4833
4834
# File 'lib/syntax_tree/node.rb', line 4832

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

#format(q) ⇒ Object



4836
4837
4838
4839
# File 'lib/syntax_tree/node.rb', line 4836

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

#ignore?Boolean

Returns:

  • (Boolean)


4818
4819
4820
# File 'lib/syntax_tree/node.rb', line 4818

def ignore?
  false
end

#inline?Boolean

Returns:

  • (Boolean)


4814
4815
4816
# File 'lib/syntax_tree/node.rb', line 4814

def inline?
  false
end

#pretty_print(q) ⇒ Object



4841
4842
4843
4844
4845
4846
4847
4848
# File 'lib/syntax_tree/node.rb', line 4841

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

    q.breakable
    q.pp(value)
  end
end

#to_json(*opts) ⇒ Object



4850
4851
4852
# File 'lib/syntax_tree/node.rb', line 4850

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