Class: SyntaxTree::XString
Overview
XString represents the contents of an XStringLiteral.
`ls`
Instance Attribute Summary collapse
-
#parts ⇒ Object
readonly
- Array[ StringEmbExpr | StringDVar | TStringContent ]
-
the parts of the xstring.
Attributes inherited from Node
Instance Method Summary collapse
- #===(other) ⇒ Object
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #copy(parts: nil, location: nil) ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
-
#initialize(parts:, location:) ⇒ XString
constructor
A new instance of XString.
Methods inherited from Node
#construct_keys, #end_char, #format, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(parts:, location:) ⇒ XString
Returns a new instance of XString.
12200 12201 12202 12203 |
# File 'lib/syntax_tree/node.rb', line 12200 def initialize(parts:, location:) @parts = parts @location = location end |
Instance Attribute Details
#parts ⇒ Object (readonly)
- Array[ StringEmbExpr | StringDVar | TStringContent ]
-
the parts of the
xstring
12198 12199 12200 |
# File 'lib/syntax_tree/node.rb', line 12198 def parts @parts end |
Instance Method Details
#===(other) ⇒ Object
12226 12227 12228 |
# File 'lib/syntax_tree/node.rb', line 12226 def ===(other) other.is_a?(XString) && ArrayMatch.call(parts, other.parts) end |
#accept(visitor) ⇒ Object
12205 12206 12207 |
# File 'lib/syntax_tree/node.rb', line 12205 def accept(visitor) visitor.visit_xstring(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
12209 12210 12211 |
# File 'lib/syntax_tree/node.rb', line 12209 def child_nodes parts end |
#copy(parts: nil, location: nil) ⇒ Object
12213 12214 12215 12216 12217 12218 |
# File 'lib/syntax_tree/node.rb', line 12213 def copy(parts: nil, location: nil) XString.new( parts: parts || self.parts, location: location || self.location ) end |
#deconstruct_keys(_keys) ⇒ Object
12222 12223 12224 |
# File 'lib/syntax_tree/node.rb', line 12222 def deconstruct_keys(_keys) { parts: parts, location: location } end |