Class: SyntaxTree::XString
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::XString
show all
- Defined in:
- lib/syntax_tree/node.rb
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
#location
Instance Method Summary
collapse
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.
12203
12204
12205
12206
|
# File 'lib/syntax_tree/node.rb', line 12203
def initialize(parts:, location:)
@parts = parts
@location = location
end
|
Instance Attribute Details
#parts ⇒ Object
[Array[ StringEmbExpr | StringDVar | TStringContent ]] the parts of the
xstring
12201
12202
12203
|
# File 'lib/syntax_tree/node.rb', line 12201
def parts
@parts
end
|
Instance Method Details
#===(other) ⇒ Object
12229
12230
12231
|
# File 'lib/syntax_tree/node.rb', line 12229
def ===(other)
other.is_a?(XString) && ArrayMatch.call(parts, other.parts)
end
|
#accept(visitor) ⇒ Object
12208
12209
12210
|
# File 'lib/syntax_tree/node.rb', line 12208
def accept(visitor)
visitor.visit_xstring(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
12212
12213
12214
|
# File 'lib/syntax_tree/node.rb', line 12212
def child_nodes
parts
end
|
#copy(parts: nil, location: nil) ⇒ Object
12216
12217
12218
12219
12220
12221
|
# File 'lib/syntax_tree/node.rb', line 12216
def copy(parts: nil, location: nil)
XString.new(
parts: parts || self.parts,
location: location || self.location
)
end
|
#deconstruct_keys(_keys) ⇒ Object
12225
12226
12227
|
# File 'lib/syntax_tree/node.rb', line 12225
def deconstruct_keys(_keys)
{ parts: parts, location: location }
end
|