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.
12184
12185
12186
12187
|
# File 'lib/syntax_tree/node.rb', line 12184
def initialize(parts:, location:)
@parts = parts
@location = location
end
|
Instance Attribute Details
#parts ⇒ Object
[Array[ StringEmbExpr | StringDVar | TStringContent ]] the parts of the
xstring
12182
12183
12184
|
# File 'lib/syntax_tree/node.rb', line 12182
def parts
@parts
end
|
Instance Method Details
#===(other) ⇒ Object
12210
12211
12212
|
# File 'lib/syntax_tree/node.rb', line 12210
def ===(other)
other.is_a?(XString) && ArrayMatch.call(parts, other.parts)
end
|
#accept(visitor) ⇒ Object
12189
12190
12191
|
# File 'lib/syntax_tree/node.rb', line 12189
def accept(visitor)
visitor.visit_xstring(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
12193
12194
12195
|
# File 'lib/syntax_tree/node.rb', line 12193
def child_nodes
parts
end
|
#copy(parts: nil, location: nil) ⇒ Object
12197
12198
12199
12200
12201
12202
|
# File 'lib/syntax_tree/node.rb', line 12197
def copy(parts: nil, location: nil)
XString.new(
parts: parts || self.parts,
location: location || self.location
)
end
|
#deconstruct_keys(_keys) ⇒ Object
12206
12207
12208
|
# File 'lib/syntax_tree/node.rb', line 12206
def deconstruct_keys(_keys)
{ parts: parts, location: location }
end
|