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.
10984
10985
10986
10987
10988
|
# File 'lib/syntax_tree/node.rb', line 10984
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
10982
10983
10984
|
# File 'lib/syntax_tree/node.rb', line 10982
def
@comments
end
|
#value ⇒ Object
- String
-
the content of the string
10979
10980
10981
|
# File 'lib/syntax_tree/node.rb', line 10979
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
11023
11024
11025
|
# File 'lib/syntax_tree/node.rb', line 11023
def ===(other)
other.is_a?(TStringContent) && value === other.value
end
|
#accept(visitor) ⇒ Object
10994
10995
10996
|
# File 'lib/syntax_tree/node.rb', line 10994
def accept(visitor)
visitor.visit_tstring_content(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
10998
10999
11000
|
# File 'lib/syntax_tree/node.rb', line 10998
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
|
# File 'lib/syntax_tree/node.rb', line 11002
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
11015
11016
11017
|
# File 'lib/syntax_tree/node.rb', line 11015
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
11019
11020
11021
|
# File 'lib/syntax_tree/node.rb', line 11019
def format(q)
q.text(value)
end
|
#match?(pattern) ⇒ Boolean
10990
10991
10992
|
# File 'lib/syntax_tree/node.rb', line 10990
def match?(pattern)
value.match?(pattern)
end
|