class Prism::Source

def find_line(byte_offset)

Experimental RBS support (using type sampling data from the type_fusion project).

def find_line: (Integer byte_offset) -> Integer

This signature was generated using 26 samples from 1 application.

byte offset.
Binary search through the offsets to find the line number for the given
def find_line(byte_offset)
  left = 0
  right = offsets.length - 1
  while left <= right
    mid = left + (right - left) / 2
    return mid if offsets[mid] == byte_offset
    if offsets[mid] < byte_offset
      left = mid + 1
    else
      right = mid - 1
    end
  end
  left - 1
end