module BinData::IO::Common::SeekableStream

Use seek and pos on seekable streams

Public Instance Methods

num_bytes_remaining() click to toggle source

The number of bytes remaining in the input stream.

# File lib/bindata/io.rb, line 71
def num_bytes_remaining
  mark = @raw_io.pos
  @raw_io.seek(0, ::IO::SEEK_END)
  bytes_remaining = @raw_io.pos - mark
  @raw_io.seek(mark, ::IO::SEEK_SET)

  bytes_remaining
end

Private Instance Methods

offset_raw() click to toggle source
# File lib/bindata/io.rb, line 87
def offset_raw
  @raw_io.pos - @initial_pos
end
read_raw(n) click to toggle source
# File lib/bindata/io.rb, line 95
def read_raw(n)
  @raw_io.read(n)
end
seek_raw(n) click to toggle source
# File lib/bindata/io.rb, line 91
def seek_raw(n)
  @raw_io.seek(n, ::IO::SEEK_CUR)
end
stream_init() click to toggle source
# File lib/bindata/io.rb, line 83
def stream_init
  @initial_pos = @raw_io.pos
end
write_raw(data) click to toggle source
# File lib/bindata/io.rb, line 99
def write_raw(data)
  @raw_io.write(data)
end