Class: SyntaxTree::EmbDoc
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::EmbDoc
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
Methods inherited from Node
#construct_keys, #end_char, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(value:, location:) ⇒ EmbDoc
Returns a new instance of EmbDoc.
4959
4960
4961
4962
4963
4964
4965
|
# File 'lib/syntax_tree/node.rb', line 4959
def initialize(value:, location:)
@value = value
@location = location
@leading = false
@trailing = false
end
|
Instance Attribute Details
#value ⇒ Object
- String
-
the contents of the comment
4957
4958
4959
|
# File 'lib/syntax_tree/node.rb', line 4957
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
5027
5028
5029
|
# File 'lib/syntax_tree/node.rb', line 5027
def ===(other)
other.is_a?(EmbDoc) && value === other.value
end
|
#accept(visitor) ⇒ Object
4995
4996
4997
|
# File 'lib/syntax_tree/node.rb', line 4995
def accept(visitor)
visitor.visit_embdoc(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
4999
5000
5001
|
# File 'lib/syntax_tree/node.rb', line 4999
def child_nodes
[]
end
|
4991
4992
4993
|
# File 'lib/syntax_tree/node.rb', line 4991
def
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
5003
5004
5005
5006
5007
5008
|
# File 'lib/syntax_tree/node.rb', line 5003
def copy(value: nil, location: nil)
EmbDoc.new(
value: value || self.value,
location: location || self.location
)
end
|
#deconstruct_keys(_keys) ⇒ Object
5012
5013
5014
|
# File 'lib/syntax_tree/node.rb', line 5012
def deconstruct_keys(_keys)
{ value: value, location: location }
end
|
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
|
# File 'lib/syntax_tree/node.rb', line 5016
def format(q)
if (q.parent.is_a?(DefNode) && q.parent.endless?) ||
q.parent.is_a?(Statements)
q.trim
else
q.breakable_return
end
q.text(value)
end
|
#ignore? ⇒ Boolean
4987
4988
4989
|
# File 'lib/syntax_tree/node.rb', line 4987
def ignore?
false
end
|
#inline? ⇒ Boolean
4983
4984
4985
|
# File 'lib/syntax_tree/node.rb', line 4983
def inline?
false
end
|
#leading! ⇒ Object
4967
4968
4969
|
# File 'lib/syntax_tree/node.rb', line 4967
def leading!
@leading = true
end
|
#leading? ⇒ Boolean
4971
4972
4973
|
# File 'lib/syntax_tree/node.rb', line 4971
def leading?
@leading
end
|
#trailing! ⇒ Object
4975
4976
4977
|
# File 'lib/syntax_tree/node.rb', line 4975
def trailing!
@trailing = true
end
|
#trailing? ⇒ Boolean
4979
4980
4981
|
# File 'lib/syntax_tree/node.rb', line 4979
def trailing?
@trailing
end
|