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, #pretty_print, #to_json
Constructor Details
#initialize(parts:, location:) ⇒ XStringLiteral
Returns a new instance of XStringLiteral.
12058
12059
12060
12061
12062
|
# File 'lib/syntax_tree/node.rb', line 12058
def initialize(parts:, location:)
@parts = parts
@location = location
@comments = []
end
|
Instance Attribute Details
[Array[ Comment | EmbDoc ]] the comments attached to this node
12056
12057
12058
|
# File 'lib/syntax_tree/node.rb', line 12056
def
@comments
end
|
#parts ⇒ Object
[Array[ StringEmbExpr | StringDVar | TStringContent ]] the parts of the
xstring
12053
12054
12055
|
# File 'lib/syntax_tree/node.rb', line 12053
def parts
@parts
end
|
Instance Method Details
#===(other) ⇒ Object
12095
12096
12097
|
# File 'lib/syntax_tree/node.rb', line 12095
def ===(other)
other.is_a?(XStringLiteral) && ArrayMatch.call(parts, other.parts)
end
|
#accept(visitor) ⇒ Object
12064
12065
12066
|
# File 'lib/syntax_tree/node.rb', line 12064
def accept(visitor)
visitor.visit_xstring_literal(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
12068
12069
12070
|
# File 'lib/syntax_tree/node.rb', line 12068
def child_nodes
parts
end
|
#copy(parts: nil, location: nil) ⇒ Object
12072
12073
12074
12075
12076
12077
12078
12079
12080
12081
|
# File 'lib/syntax_tree/node.rb', line 12072
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
12085
12086
12087
|
# File 'lib/syntax_tree/node.rb', line 12085
def deconstruct_keys(_keys)
{ parts: parts, location: location, comments: }
end
|
12089
12090
12091
12092
12093
|
# File 'lib/syntax_tree/node.rb', line 12089
def format(q)
q.text("`")
q.format_each(parts)
q.text("`")
end
|