Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Prism::Source#compute_offsets
compute_offsets(code)
lib/prism/parse_result.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/lib/prism/parse_result.rb, line 83
def compute_offsets(code)
offsets = [0]
code.b.scan("\n") { offsets << $~.end(0) }
offsets
end
Find all of the newlines in the source code and return their byte offsets from the start of the string an array.