Module: BinData::IO::UnSeekableIO
- Defined in:
- lib/bindata/io.rb
Overview
A module to be prepended to RawIO
or Transform
when the data stream is not seekable. This is either due to underlying stream being unseekable or the transform changes the number of bytes.
Instance Method Summary collapse
Instance Method Details
#num_bytes_remaining ⇒ Object
499 500 501 |
# File 'lib/bindata/io.rb', line 499 def num_bytes_remaining raise IOError, "stream is unseekable" end |
#seek_abs(n) ⇒ Object
514 515 516 |
# File 'lib/bindata/io.rb', line 514 def seek_abs(n) skip(n - offset) end |
#seekable? ⇒ Boolean
495 496 497 |
# File 'lib/bindata/io.rb', line 495 def seekable? false end |
#skip(n) ⇒ Object
503 504 505 506 507 508 509 510 511 512 |
# File 'lib/bindata/io.rb', line 503 def skip(n) raise IOError, "can not skip backwards" if n.negative? # skip over data in 8k blocks while n > 0 bytes_to_read = [n, 8192].min read(bytes_to_read) n -= bytes_to_read end end |