Class: ZSTDS::Stream::Raw::Decompressor
- Defined in:
- lib/zstds/stream/raw/decompressor.rb
Constant Summary collapse
- BUFFER_LENGTH_NAMES =
i[destination_buffer_length].freeze
Instance Method Summary collapse
- #close(&writer) ⇒ Object
- #flush(&writer) ⇒ Object
-
#initialize(options = {}) ⇒ Decompressor
constructor
A new instance of Decompressor.
- #read(source, &writer) ⇒ Object
Methods inherited from Abstract
Constructor Details
#initialize(options = {}) ⇒ Decompressor
Returns a new instance of Decompressor.
16 17 18 19 20 21 |
# File 'lib/zstds/stream/raw/decompressor.rb', line 16 def initialize( = {}) = Option. , BUFFER_LENGTH_NAMES native_stream = NativeDecompressor.new super native_stream end |
Instance Method Details
#close(&writer) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/zstds/stream/raw/decompressor.rb', line 56 def close(&writer) return nil if closed? Validation.validate_proc writer super end |
#flush(&writer) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/zstds/stream/raw/decompressor.rb', line 48 def flush(&writer) do_not_use_after_close Validation.validate_proc writer super end |
#read(source, &writer) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/zstds/stream/raw/decompressor.rb', line 23 def read(source, &writer) do_not_use_after_close Validation.validate_string source Validation.validate_proc writer total_bytes_read = 0 loop do bytes_read, need_more_destination = @native_stream.read source total_bytes_read += bytes_read if need_more_destination source = source.byteslice bytes_read, source.bytesize - bytes_read more_destination(&writer) next end break end # Please remember that "total_bytes_read" can not be equal to "source.bytesize". total_bytes_read end |