Use seek and pos on seekable streams
The number of bytes remaining in the input stream.
# File lib/bindata/io.rb, line 71 def num_bytes_remaining start_mark = @raw_io.pos @raw_io.seek(0, ::IO::SEEK_END) end_mark = @raw_io.pos if @buffer_end_points if @buffer_end_points[1] < end_mark end_mark = @buffer_end_points[1] end end bytes_remaining = end_mark - start_mark @raw_io.seek(start_mark, ::IO::SEEK_SET) bytes_remaining end
All io calls in block are rolled back after this method
completes.
# File lib/bindata/io.rb, line 90 def with_readahead mark = @raw_io.pos begin yield ensure @raw_io.seek(mark, ::IO::SEEK_SET) end end