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.



5149
5150
5151
5152
# File 'lib/syntax_tree.rb', line 5149

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

Instance Attribute Details

#locationObject (readonly)

Location

the location of this node



5147
5148
5149
# File 'lib/syntax_tree.rb', line 5147

def location
  @location
end

#valueObject (readonly)

String

the contents of the comment



5144
5145
5146
# File 'lib/syntax_tree.rb', line 5144

def value
  @value
end

Instance Method Details

#child_nodesObject



5162
5163
5164
# File 'lib/syntax_tree.rb', line 5162

def child_nodes
  []
end

#commentsObject



5158
5159
5160
# File 'lib/syntax_tree.rb', line 5158

def comments
  []
end

#format(q) ⇒ Object



5166
5167
5168
5169
# File 'lib/syntax_tree.rb', line 5166

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

#inline?Boolean

Returns:

  • (Boolean)


5154
5155
5156
# File 'lib/syntax_tree.rb', line 5154

def inline?
  false
end

#pretty_print(q) ⇒ Object



5171
5172
5173
5174
5175
5176
5177
5178
# File 'lib/syntax_tree.rb', line 5171

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

    q.breakable
    q.pp(value)
  end
end

#to_json(*opts) ⇒ Object



5180
5181
5182
# File 'lib/syntax_tree.rb', line 5180

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