Module: BinData::IO::Common::UnSeekableStream
- Defined in:
- lib/bindata/io.rb
Overview
Manually keep track of offset for unseekable streams.
Instance Method Summary collapse
-
#num_bytes_remaining ⇒ Object
The number of bytes remaining in the input stream.
- #offset_raw ⇒ Object
-
#with_readahead ⇒ Object
All io calls in
block
are rolled back after this method completes.
Instance Method Details
#num_bytes_remaining ⇒ Object
The number of bytes remaining in the input stream.
130 131 132 |
# File 'lib/bindata/io.rb', line 130 def num_bytes_remaining raise IOError, "stream is unseekable" end |
#offset_raw ⇒ Object
125 126 127 |
# File 'lib/bindata/io.rb', line 125 def offset_raw @offset end |
#with_readahead ⇒ Object
All io calls in block
are rolled back after this method completes.
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/bindata/io.rb', line 136 def with_readahead mark = @offset @read_data = "" @in_readahead = true class << self alias_method :read_raw_without_readahead, :read_raw alias_method :read_raw, :read_raw_with_readahead end begin yield ensure @offset = mark @in_readahead = false end end |