Class: SyntaxTree::TStringContent
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::TStringContent
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
TStringContent represents plain characters inside of an entity that accepts string content like a string, heredoc, command string, or regular expression.
"string"
In the example above, TStringContent represents the string token contained within the string.
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:) ⇒ TStringContent
Returns a new instance of TStringContent.
10999
11000
11001
11002
11003
|
# File 'lib/syntax_tree/node.rb', line 10999
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
10997
10998
10999
|
# File 'lib/syntax_tree/node.rb', line 10997
def
@comments
end
|
#value ⇒ Object
- String
-
the content of the string
10994
10995
10996
|
# File 'lib/syntax_tree/node.rb', line 10994
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
11038
11039
11040
|
# File 'lib/syntax_tree/node.rb', line 11038
def ===(other)
other.is_a?(TStringContent) && value === other.value
end
|
#accept(visitor) ⇒ Object
11009
11010
11011
|
# File 'lib/syntax_tree/node.rb', line 11009
def accept(visitor)
visitor.visit_tstring_content(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
11013
11014
11015
|
# File 'lib/syntax_tree/node.rb', line 11013
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
|
# File 'lib/syntax_tree/node.rb', line 11017
def copy(value: nil, location: nil)
node =
TStringContent.new(
value: value || self.value,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
11030
11031
11032
|
# File 'lib/syntax_tree/node.rb', line 11030
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
11034
11035
11036
|
# File 'lib/syntax_tree/node.rb', line 11034
def format(q)
q.text(value)
end
|
#match?(pattern) ⇒ Boolean
11005
11006
11007
|
# File 'lib/syntax_tree/node.rb', line 11005
def match?(pattern)
value.match?(pattern)
end
|