Class: SyntaxTree::StringContent
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::StringContent
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
StringContent represents the contents of a string-like value.
"string"
Instance Attribute Summary collapse
-
#parts ⇒ Object
readonly
- Array[ StringEmbExpr | StringDVar | TStringContent ]
-
the parts of the string.
Attributes inherited from Node
#location
Instance Method Summary
collapse
Methods inherited from Node
#construct_keys, #format, #pretty_print, #to_json
Constructor Details
#initialize(parts:, location:) ⇒ StringContent
9948
9949
9950
9951
|
# File 'lib/syntax_tree/node.rb', line 9948
def initialize(parts:, location:)
@parts = parts
@location = location
end
|
Instance Attribute Details
#parts ⇒ Object
- Array[ StringEmbExpr | StringDVar | TStringContent ]
-
the parts of the
string
9946
9947
9948
|
# File 'lib/syntax_tree/node.rb', line 9946
def parts
@parts
end
|
Instance Method Details
#===(other) ⇒ Object
9974
9975
9976
|
# File 'lib/syntax_tree/node.rb', line 9974
def ===(other)
other.is_a?(StringContent) && ArrayMatch.call(parts, other.parts)
end
|
#accept(visitor) ⇒ Object
9953
9954
9955
|
# File 'lib/syntax_tree/node.rb', line 9953
def accept(visitor)
visitor.visit_string_content(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
9957
9958
9959
|
# File 'lib/syntax_tree/node.rb', line 9957
def child_nodes
parts
end
|
#copy(parts: nil, location: nil) ⇒ Object
9961
9962
9963
9964
9965
9966
|
# File 'lib/syntax_tree/node.rb', line 9961
def copy(parts: nil, location: nil)
StringContent.new(
parts: parts || self.parts,
location: location || self.location
)
end
|
#deconstruct_keys(_keys) ⇒ Object
9970
9971
9972
|
# File 'lib/syntax_tree/node.rb', line 9970
def deconstruct_keys(_keys)
{ parts: parts, location: location }
end
|