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.
9913 9914 9915 9916 |
# File 'lib/syntax_tree/node.rb', line 9913 def initialize(parts:, location:) @parts = parts @location = location end |
Instance Attribute Details
#parts ⇒ Object (readonly)
- Array[ StringEmbExpr | StringDVar | TStringContent ]
-
the parts of the
string
9911 9912 9913 |
# File 'lib/syntax_tree/node.rb', line 9911 def parts @parts end |
Instance Method Details
#===(other) ⇒ Object
9939 9940 9941 |
# File 'lib/syntax_tree/node.rb', line 9939 def ===(other) other.is_a?(StringContent) && ArrayMatch.call(parts, other.parts) end |
#accept(visitor) ⇒ Object
9918 9919 9920 |
# File 'lib/syntax_tree/node.rb', line 9918 def accept(visitor) visitor.visit_string_content(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9922 9923 9924 |
# File 'lib/syntax_tree/node.rb', line 9922 def child_nodes parts end |
#copy(parts: nil, location: nil) ⇒ Object
9926 9927 9928 9929 9930 9931 |
# File 'lib/syntax_tree/node.rb', line 9926 def copy(parts: nil, location: nil) StringContent.new( parts: parts || self.parts, location: location || self.location ) end |
#deconstruct_keys(_keys) ⇒ Object
9935 9936 9937 |
# File 'lib/syntax_tree/node.rb', line 9935 def deconstruct_keys(_keys) { parts: parts, location: location } end |