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, #pretty_print, #to_json
Constructor Details
#initialize(parts:, location:) ⇒ XStringLiteral
Returns a new instance of XStringLiteral.
12049 12050 12051 12052 12053 |
# File 'lib/syntax_tree/node.rb', line 12049 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
12047 12048 12049 |
# File 'lib/syntax_tree/node.rb', line 12047 def comments @comments end |
#parts ⇒ Object (readonly)
- Array[ StringEmbExpr | StringDVar | TStringContent ]
-
the parts of the
xstring
12044 12045 12046 |
# File 'lib/syntax_tree/node.rb', line 12044 def parts @parts end |
Instance Method Details
#===(other) ⇒ Object
12086 12087 12088 |
# File 'lib/syntax_tree/node.rb', line 12086 def ===(other) other.is_a?(XStringLiteral) && ArrayMatch.call(parts, other.parts) end |
#accept(visitor) ⇒ Object
12055 12056 12057 |
# File 'lib/syntax_tree/node.rb', line 12055 def accept(visitor) visitor.visit_xstring_literal(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
12059 12060 12061 |
# File 'lib/syntax_tree/node.rb', line 12059 def child_nodes parts end |
#copy(parts: nil, location: nil) ⇒ Object
12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 |
# File 'lib/syntax_tree/node.rb', line 12063 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
12076 12077 12078 |
# File 'lib/syntax_tree/node.rb', line 12076 def deconstruct_keys(_keys) { parts: parts, location: location, comments: comments } end |
#format(q) ⇒ Object
12080 12081 12082 12083 12084 |
# File 'lib/syntax_tree/node.rb', line 12080 def format(q) q.text("`") q.format_each(parts) q.text("`") end |