instance method
Prism::Source#find_line
find_line(byte_offset)
lib/prism/parse_result.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/prism/parse_result.rb, line 157
def find_line(byte_offset)
index = offsets.bsearch_index { |offset| offset > byte_offset } || offsets.length
index - 1
end
Binary search through the offsets to find the line number for the given byte offset.