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.
11000
11001
11002
11003
11004
|
# File 'lib/syntax_tree/node.rb', line 11000
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
10998
10999
11000
|
# File 'lib/syntax_tree/node.rb', line 10998
def
@comments
end
|
#value ⇒ Object
- String
-
the content of the string
10995
10996
10997
|
# File 'lib/syntax_tree/node.rb', line 10995
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
11039
11040
11041
|
# File 'lib/syntax_tree/node.rb', line 11039
def ===(other)
other.is_a?(TStringContent) && value === other.value
end
|
#accept(visitor) ⇒ Object
11010
11011
11012
|
# File 'lib/syntax_tree/node.rb', line 11010
def accept(visitor)
visitor.visit_tstring_content(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
11014
11015
11016
|
# File 'lib/syntax_tree/node.rb', line 11014
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
|
# File 'lib/syntax_tree/node.rb', line 11018
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
11031
11032
11033
|
# File 'lib/syntax_tree/node.rb', line 11031
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
11035
11036
11037
|
# File 'lib/syntax_tree/node.rb', line 11035
def format(q)
q.text(value)
end
|
#match?(pattern) ⇒ Boolean
11006
11007
11008
|
# File 'lib/syntax_tree/node.rb', line 11006
def match?(pattern)
value.match?(pattern)
end
|