class SyntaxTree::StringContent
StringContent
represents the contents of a string-like value.
"string"
Attributes
- Array[
StringEmbExpr
|StringDVar
|TStringContent
] -
the parts of the
string
Public Class Methods
Source
# File lib/syntax_tree/node.rb, line 10074 def initialize(parts:, location:) @parts = parts @location = location @comments = [] end
Public Instance Methods
Source
# File lib/syntax_tree/node.rb, line 10101 def ===(other) other.is_a?(StringContent) && ArrayMatch.call(parts, other.parts) end
Source
# File lib/syntax_tree/node.rb, line 10080 def accept(visitor) visitor.visit_string_content(self) end
Source
# File lib/syntax_tree/node.rb, line 10084 def child_nodes parts end
Also aliased as: deconstruct
Source
# File lib/syntax_tree/node.rb, line 10088 def copy(parts: nil, location: nil) StringContent.new( parts: parts || self.parts, location: location || self.location ) end
Source
# File lib/syntax_tree/node.rb, line 10097 def deconstruct_keys(_keys) { parts: parts, location: location } end
Source
# File lib/syntax_tree/node.rb, line 10105 def format(q) q.text(q.quote) q.group do parts.each do |part| if part.is_a?(TStringContent) value = Quotes.normalize(part.value, q.quote) first = true value.each_line(chomp: true) do |line| if first first = false else q.breakable_return end q.text(line) end q.breakable_return if value.end_with?("\n") else q.format(part) end end end q.text(q.quote) end