Module: BinData::IO::Read::SeekableStream
- Defined in:
- lib/bindata/io.rb
Overview
Use #seek and #pos on seekable streams
Instance Method Summary collapse
-
#num_bytes_remaining ⇒ Object
The number of bytes remaining in the input stream.
-
#offset ⇒ Object
Returns the current offset of the io stream.
Instance Method Details
#num_bytes_remaining ⇒ Object
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 |
#offset ⇒ Object
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 |