Class: SyntaxTree::XStringLiteral
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::XStringLiteral
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
XStringLiteral represents a string that gets executed.
`ls`
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
[Array[ Comment | EmbDoc ]] the comments attached to this node.
-
#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, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(parts:, location:) ⇒ XStringLiteral
Returns a new instance of XStringLiteral.
12246
12247
12248
12249
12250
|
# File 'lib/syntax_tree/node.rb', line 12246
def initialize(parts:, location:)
@parts = parts
@location = location
= []
end
|
Instance Attribute Details
[Array[ Comment | EmbDoc ]] the comments attached to this node
12244
12245
12246
|
# File 'lib/syntax_tree/node.rb', line 12244
def
end
|
#parts ⇒ Object
[Array[ StringEmbExpr | StringDVar | TStringContent ]] the parts of the
xstring
12241
12242
12243
|
# File 'lib/syntax_tree/node.rb', line 12241
def parts
@parts
end
|
Instance Method Details
#===(other) ⇒ Object
12283
12284
12285
|
# File 'lib/syntax_tree/node.rb', line 12283
def ===(other)
other.is_a?(XStringLiteral) && ArrayMatch.call(parts, other.parts)
end
|
#accept(visitor) ⇒ Object
12252
12253
12254
|
# File 'lib/syntax_tree/node.rb', line 12252
def accept(visitor)
visitor.visit_xstring_literal(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
12256
12257
12258
|
# File 'lib/syntax_tree/node.rb', line 12256
def child_nodes
parts
end
|
#copy(parts: nil, location: nil) ⇒ Object
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
|
# File 'lib/syntax_tree/node.rb', line 12260
def copy(parts: nil, location: nil)
node =
XStringLiteral.new(
parts: parts || self.parts,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
12273
12274
12275
|
# File 'lib/syntax_tree/node.rb', line 12273
def deconstruct_keys(_keys)
{ parts: parts, location: location, comments: }
end
|
12277
12278
12279
12280
12281
|
# File 'lib/syntax_tree/node.rb', line 12277
def format(q)
q.text("`")
q.format_each(parts)
q.text("`")
end
|