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.
10967
10968
10969
10970
10971
|
# File 'lib/syntax_tree/node.rb', line 10967
def initialize(value:, location:)
@value = value
@location = location
= []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
10965
10966
10967
|
# File 'lib/syntax_tree/node.rb', line 10965
def
end
|
#value ⇒ Object
- String
-
the content of the string
10962
10963
10964
|
# File 'lib/syntax_tree/node.rb', line 10962
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
11006
11007
11008
|
# File 'lib/syntax_tree/node.rb', line 11006
def ===(other)
other.is_a?(TStringContent) && value === other.value
end
|
#accept(visitor) ⇒ Object
10977
10978
10979
|
# File 'lib/syntax_tree/node.rb', line 10977
def accept(visitor)
visitor.visit_tstring_content(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
10981
10982
10983
|
# File 'lib/syntax_tree/node.rb', line 10981
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
|
# File 'lib/syntax_tree/node.rb', line 10985
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
10998
10999
11000
|
# File 'lib/syntax_tree/node.rb', line 10998
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
11002
11003
11004
|
# File 'lib/syntax_tree/node.rb', line 11002
def format(q)
q.text(value)
end
|
#match?(pattern) ⇒ Boolean
10973
10974
10975
|
# File 'lib/syntax_tree/node.rb', line 10973
def match?(pattern)
value.match?(pattern)
end
|