module IO::Stream::Readable

def index_of(pattern, offset, limit, discard = false)

@returns [Integer | Nil] The index of the pattern, or nil if not found.
@parameter limit [Integer | Nil] The maximum number of bytes to read while searching.
@parameter offset [Integer] The offset to start searching from.
@parameter pattern [String] The pattern to search for.
Find the index of a pattern in the read buffer, reading more data if needed.
def index_of(pattern, offset, limit, discard = false)
n't want to split on the pattern, so we subtract the size of the pattern.
ffset = pattern.bytesize - 1
ndex = @read_buffer.index(pattern, offset)
 = @read_buffer.bytesize - split_offset
 = 0 if offset < 0
it and offset >= limit
n nil
 fill_read_buffer
n nil
card
we are discarding, we should consume the read buffer up to the offset:
me_read_buffer(offset)
t = 0
index