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, #pretty_print, #to_json
Constructor Details
#initialize(value:, location:) ⇒ TStringContent
Returns a new instance of TStringContent.
10808
10809
10810
10811
10812
|
# File 'lib/syntax_tree/node.rb', line 10808
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
10806
10807
10808
|
# File 'lib/syntax_tree/node.rb', line 10806
def
@comments
end
|
#value ⇒ Object
- String
-
the content of the string
10803
10804
10805
|
# File 'lib/syntax_tree/node.rb', line 10803
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
10847
10848
10849
|
# File 'lib/syntax_tree/node.rb', line 10847
def ===(other)
other.is_a?(TStringContent) && value === other.value
end
|
#accept(visitor) ⇒ Object
10818
10819
10820
|
# File 'lib/syntax_tree/node.rb', line 10818
def accept(visitor)
visitor.visit_tstring_content(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
10822
10823
10824
|
# File 'lib/syntax_tree/node.rb', line 10822
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
|
# File 'lib/syntax_tree/node.rb', line 10826
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
10839
10840
10841
|
# File 'lib/syntax_tree/node.rb', line 10839
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
10843
10844
10845
|
# File 'lib/syntax_tree/node.rb', line 10843
def format(q)
q.text(value)
end
|
#match?(pattern) ⇒ Boolean
10814
10815
10816
|
# File 'lib/syntax_tree/node.rb', line 10814
def match?(pattern)
value.match?(pattern)
end
|