Class: SyntaxTree::XStringLiteral
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
Instance Method Summary collapse
- #===(other) ⇒ Object
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #copy(parts: nil, location: nil) ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(parts:, location:) ⇒ XStringLiteral
constructor
A new instance of XStringLiteral.
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.
12179 12180 12181 12182 12183 |
# File 'lib/syntax_tree/node.rb', line 12179 def initialize(parts:, location:) @parts = parts @location = location @comments = [] end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
12177 12178 12179 |
# File 'lib/syntax_tree/node.rb', line 12177 def comments @comments end |
#parts ⇒ Object (readonly)
- Array[ StringEmbExpr | StringDVar | TStringContent ]
-
the parts of the
xstring
12174 12175 12176 |
# File 'lib/syntax_tree/node.rb', line 12174 def parts @parts end |
Instance Method Details
#===(other) ⇒ Object
12216 12217 12218 |
# File 'lib/syntax_tree/node.rb', line 12216 def ===(other) other.is_a?(XStringLiteral) && ArrayMatch.call(parts, other.parts) end |
#accept(visitor) ⇒ Object
12185 12186 12187 |
# File 'lib/syntax_tree/node.rb', line 12185 def accept(visitor) visitor.visit_xstring_literal(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
12189 12190 12191 |
# File 'lib/syntax_tree/node.rb', line 12189 def child_nodes parts end |
#copy(parts: nil, location: nil) ⇒ Object
12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 |
# File 'lib/syntax_tree/node.rb', line 12193 def copy(parts: nil, location: nil) node = XStringLiteral.new( parts: parts || self.parts, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end |
#deconstruct_keys(_keys) ⇒ Object
12206 12207 12208 |
# File 'lib/syntax_tree/node.rb', line 12206 def deconstruct_keys(_keys) { parts: parts, location: location, comments: comments } end |
#format(q) ⇒ Object
12210 12211 12212 12213 12214 |
# File 'lib/syntax_tree/node.rb', line 12210 def format(q) q.text("`") q.format_each(parts) q.text("`") end |