Class: Zstd::StreamReader
- Inherits:
-
Object
- Object
- Zstd::StreamReader
- Defined in:
- lib/zstd-ruby/stream_reader.rb
Overview
TODO:
Exprimental
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(io) ⇒ StreamReader
constructor
A new instance of StreamReader.
- #read(length) ⇒ Object
Constructor Details
#initialize(io) ⇒ StreamReader
Returns a new instance of StreamReader.
4 5 6 7 |
# File 'lib/zstd-ruby/stream_reader.rb', line 4 def initialize(io) @io = io @stream = Zstd::StreamingDecompress.new end |
Instance Method Details
#close ⇒ Object
17 18 19 20 |
# File 'lib/zstd-ruby/stream_reader.rb', line 17 def close @io.write(@stream.finish) @io.close end |
#read(length) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/zstd-ruby/stream_reader.rb', line 9 def read(length) if @io.eof? raise StandardError, "EOF" end data = @io.read(length) @stream.decompress(data) end |