# File lib/ole/ranges_io.rb, line 112 def pos= pos, whence=IO::SEEK_SET case whence when IO::SEEK_SET when IO::SEEK_CUR pos += @pos when IO::SEEK_END pos = @size + pos else raise Errno::EINVAL end raise Errno::EINVAL unless (0..@size) === pos @pos = pos # do a binary search throuh @offsets to find the active range. a, c, b = 0, 0, @offsets.length while a < b c = (a + b).div(2) pivot = @offsets[c] if pos == pivot @active = c return elsif pos < pivot b = c else a = c + 1 end end @active = a - 1 end