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.



200
201
202
203
204
205
206
207
# File 'lib/bindata/io.rb', line 200

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. The exact value of the offset when reading bitfields is not defined.



195
196
197
# File 'lib/bindata/io.rb', line 195

def offset
  raw_io.pos - @initial_pos
end