Class: SyntaxTree::StringContent
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
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:) ⇒ StringContent
constructor
A new instance of StringContent.
Methods inherited from Node
#construct_keys, #format, #pretty_print, #to_json
Constructor Details
#initialize(parts:, location:) ⇒ StringContent
Returns a new instance of StringContent.
9922 9923 9924 9925 |
# File 'lib/syntax_tree/node.rb', line 9922 def initialize(parts:, location:) @parts = parts @location = location end |
Instance Attribute Details
#parts ⇒ Object (readonly)
- Array[ StringEmbExpr | StringDVar | TStringContent ]
-
the parts of the
string
9920 9921 9922 |
# File 'lib/syntax_tree/node.rb', line 9920 def parts @parts end |
Instance Method Details
#===(other) ⇒ Object
9948 9949 9950 |
# File 'lib/syntax_tree/node.rb', line 9948 def ===(other) other.is_a?(StringContent) && ArrayMatch.call(parts, other.parts) end |
#accept(visitor) ⇒ Object
9927 9928 9929 |
# File 'lib/syntax_tree/node.rb', line 9927 def accept(visitor) visitor.visit_string_content(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9931 9932 9933 |
# File 'lib/syntax_tree/node.rb', line 9931 def child_nodes parts end |
#copy(parts: nil, location: nil) ⇒ Object
9935 9936 9937 9938 9939 9940 |
# File 'lib/syntax_tree/node.rb', line 9935 def copy(parts: nil, location: nil) StringContent.new( parts: parts || self.parts, location: location || self.location ) end |
#deconstruct_keys(_keys) ⇒ Object
9944 9945 9946 |
# File 'lib/syntax_tree/node.rb', line 9944 def deconstruct_keys(_keys) { parts: parts, location: location } end |