class ADSP::Stream::Raw::Decompressor
Constants
- BUFFER_LENGTH_NAMES
Current buffer length names. It is a part of decompressor options.
- NativeDecompressor
Current native decompressor class.
- Option
ADSP::Option
class.
Public Class Methods
new(options = {})
click to toggle source
Initializes decompressor. Option: :destination_buffer_length
destination buffer length.
Calls superclass method
ADSP::Stream::Raw::Abstract::new
# File lib/adsp/stream/raw/decompressor.rb, line 26 def initialize(options = {}) options = self.class::Option.get_decompressor_options options, BUFFER_LENGTH_NAMES native_stream = self.class::NativeDecompressor.new options super native_stream end
Public Instance Methods
close(&writer)
click to toggle source
Writes result using writer
proc and closes decompressor. Raises UsedAfterCloseError
when used after close.
Calls superclass method
ADSP::Stream::Raw::Abstract#close
# File lib/adsp/stream/raw/decompressor.rb, line 70 def close(&writer) return nil if closed? Validation.validate_proc writer super end
flush(&writer)
click to toggle source
Flushes decompressor, writes result using writer
proc and closes decompressor.
Calls superclass method
ADSP::Stream::Raw::Abstract#flush
# File lib/adsp/stream/raw/decompressor.rb, line 60 def flush(&writer) do_not_use_after_close Validation.validate_proc writer super end
read(source, &writer)
click to toggle source
Reads source
string, writes result using writer
proc. Returns amount of bytes read from source
.
# File lib/adsp/stream/raw/decompressor.rb, line 35 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 total_bytes_read end