Module: BinData::IO::Read::SeekableStream

Defined in:
lib/bindata/io.rb

Overview

Use #seek and #pos on seekable streams

Instance Method Summary collapse

Instance Method Details

#num_bytes_remainingObject

The number of bytes remaining in the input stream.



197
198
199
200
201
202
203
204
# File 'lib/bindata/io.rb', line 197

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

#offsetObject

Returns the current offset of the io stream. Offset will be rounded up when reading bitfields.



192
193
194
# File 'lib/bindata/io.rb', line 192

def offset
  raw_io.pos - @initial_pos
end