instance method
Prism::Translation::Ripper#visit_heredoc_node
visit_heredoc_node(parts, base) { |result, on_tstring_content(map(&:content).join)| ... }
lib/prism/translation/ripper.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/prism/translation/ripper.rb, line 3006
def visit_heredoc_node(parts, base)
common_whitespace = visit_heredoc_node_whitespace(parts)
if common_whitespace == 0
bounds(parts.first.location)
string = []
result = base
parts.each do |part|
if part.is_a?(StringNode)
if string.empty?
string = [part]
else
string << part
end
else
unless string.empty?
bounds(string[0].location)
result = yield result, on_tstring_content(string.map(&:content).join)
string = []
end
result = yield result, visit(part)
end
end
unless string.empty?
bounds(string[0].location)
result = yield result, on_tstring_content(string.map(&:content).join)
end
result
else
bounds(parts.first.location)
result =
parts.inject(base) do |string_content, part|
yield string_content, visit_string_content(part)
end
bounds(parts.first.location)
on_heredoc_dedent(result, common_whitespace)
end
end
Visit a string that is expressed using a <<~ heredoc.