instance method
Prism::Translation::Ripper#dedent_string
dedent_string(string, width)
lib/prism/translation/ripper.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/prism/translation/ripper.rb, line 3454
def dedent_string(string, width)
whitespace = 0
cursor = 0
while cursor < string.length && string[cursor].match?(/\s/) && whitespace < width
if string[cursor] == "\t"
whitespace = ((whitespace / 8 + 1) * 8)
break if whitespace > width
else
whitespace += 1
end
cursor += 1
end
string.replace(string[cursor..])
cursor
end
This method is provided by the Ripper C extension. It is called when a string needs to be dedented because of a tilde heredoc. It is expected that it will modify the string in place and return the number of bytes that were removed.