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.
12136 12137 12138 12139 |
# File 'lib/syntax_tree/node.rb', line 12136 def initialize(parts:, location:) @parts = parts @location = location end |
Instance Attribute Details
#parts ⇒ Object (readonly)
- Array[ StringEmbExpr | StringDVar | TStringContent ]
-
the parts of the
xstring
12134 12135 12136 |
# File 'lib/syntax_tree/node.rb', line 12134 def parts @parts end |
Instance Method Details
#===(other) ⇒ Object
12162 12163 12164 |
# File 'lib/syntax_tree/node.rb', line 12162 def ===(other) other.is_a?(XString) && ArrayMatch.call(parts, other.parts) end |
#accept(visitor) ⇒ Object
12141 12142 12143 |
# File 'lib/syntax_tree/node.rb', line 12141 def accept(visitor) visitor.visit_xstring(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
12145 12146 12147 |
# File 'lib/syntax_tree/node.rb', line 12145 def child_nodes parts end |
#copy(parts: nil, location: nil) ⇒ Object
12149 12150 12151 12152 12153 12154 |
# File 'lib/syntax_tree/node.rb', line 12149 def copy(parts: nil, location: nil) XString.new( parts: parts || self.parts, location: location || self.location ) end |
#deconstruct_keys(_keys) ⇒ Object
12158 12159 12160 |
# File 'lib/syntax_tree/node.rb', line 12158 def deconstruct_keys(_keys) { parts: parts, location: location } end |