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, #format, #pretty_print, #to_json
Constructor Details
#initialize(parts:, location:) ⇒ XString
Returns a new instance of XString.
12015 12016 12017 12018 |
# File 'lib/syntax_tree/node.rb', line 12015 def initialize(parts:, location:) @parts = parts @location = location end |
Instance Attribute Details
#parts ⇒ Object (readonly)
- Array[ StringEmbExpr | StringDVar | TStringContent ]
-
the parts of the
xstring
12013 12014 12015 |
# File 'lib/syntax_tree/node.rb', line 12013 def parts @parts end |
Instance Method Details
#===(other) ⇒ Object
12041 12042 12043 |
# File 'lib/syntax_tree/node.rb', line 12041 def ===(other) other.is_a?(XString) && ArrayMatch.call(parts, other.parts) end |
#accept(visitor) ⇒ Object
12020 12021 12022 |
# File 'lib/syntax_tree/node.rb', line 12020 def accept(visitor) visitor.visit_xstring(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
12024 12025 12026 |
# File 'lib/syntax_tree/node.rb', line 12024 def child_nodes parts end |
#copy(parts: nil, location: nil) ⇒ Object
12028 12029 12030 12031 12032 12033 |
# File 'lib/syntax_tree/node.rb', line 12028 def copy(parts: nil, location: nil) XString.new( parts: parts || self.parts, location: location || self.location ) end |
#deconstruct_keys(_keys) ⇒ Object
12037 12038 12039 |
# File 'lib/syntax_tree/node.rb', line 12037 def deconstruct_keys(_keys) { parts: parts, location: location } end |