Class: SyntaxTree::TStringContent
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
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#value ⇒ Object
readonly
- String
-
the content of the string.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(_keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ TStringContent
constructor
A new instance of TStringContent.
- #match?(pattern) ⇒ Boolean
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(value:, location:, comments: []) ⇒ TStringContent
Returns a new instance of TStringContent.
9147 9148 9149 9150 9151 |
# File 'lib/syntax_tree/node.rb', line 9147 def initialize(value:, location:, comments: []) @value = value @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
9145 9146 9147 |
# File 'lib/syntax_tree/node.rb', line 9145 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the content of the string
9142 9143 9144 |
# File 'lib/syntax_tree/node.rb', line 9142 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
9157 9158 9159 |
# File 'lib/syntax_tree/node.rb', line 9157 def accept(visitor) visitor.visit_tstring_content(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9161 9162 9163 |
# File 'lib/syntax_tree/node.rb', line 9161 def child_nodes [] end |
#deconstruct_keys(_keys) ⇒ Object
9167 9168 9169 |
# File 'lib/syntax_tree/node.rb', line 9167 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
9171 9172 9173 |
# File 'lib/syntax_tree/node.rb', line 9171 def format(q) q.text(value) end |
#match?(pattern) ⇒ Boolean
9153 9154 9155 |
# File 'lib/syntax_tree/node.rb', line 9153 def match?(pattern) value.match?(pattern) end |