Class: ADSP::Test::Mock::Stream::Raw::NativeCompressor
- Inherits:
-
Object
- Object
- ADSP::Test::Mock::Stream::Raw::NativeCompressor
- Defined in:
- lib/adsp/test/mock/stream/raw/native_compressor.rb
Overview
ADSP::Test::Mock::Stream::Raw::NativeCompressor class.
Instance Method Summary collapse
- #close ⇒ Object
- #finish ⇒ Object
- #flush ⇒ Object
-
#initialize(options) ⇒ NativeCompressor
constructor
A new instance of NativeCompressor.
- #read_result ⇒ Object
- #write(source) ⇒ Object
Constructor Details
#initialize(options) ⇒ NativeCompressor
Returns a new instance of NativeCompressor.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/adsp/test/mock/stream/raw/native_compressor.rb', line 16 def initialize() ADSP::Validation.validate_hash destination_buffer_length = [:destination_buffer_length] ADSP::Validation.validate_not_negative_integer destination_buffer_length destination_buffer_length = Common::DEFAULT_DESTINATION_BUFFER_LENGTH \ if destination_buffer_length.zero? @destination_buffer = "".b @destination_buffer_length = destination_buffer_length @is_closed = false end |
Instance Method Details
#close ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/adsp/test/mock/stream/raw/native_compressor.rb', line 67 def close do_not_use_after_close @is_closed = true nil end |
#finish ⇒ Object
61 62 63 64 65 |
# File 'lib/adsp/test/mock/stream/raw/native_compressor.rb', line 61 def finish do_not_use_after_close nil end |
#flush ⇒ Object
55 56 57 58 59 |
# File 'lib/adsp/test/mock/stream/raw/native_compressor.rb', line 55 def flush do_not_use_after_close nil end |
#read_result ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/adsp/test/mock/stream/raw/native_compressor.rb', line 46 def read_result do_not_use_after_close result = @destination_buffer @destination_buffer = "".b result end |
#write(source) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/adsp/test/mock/stream/raw/native_compressor.rb', line 31 def write(source) ADSP::Validation.validate_string source do_not_use_after_close remaining_destination_buffer_length = @destination_buffer_length - @destination_buffer.bytesize return [0, true] if remaining_destination_buffer_length.zero? data, bytes_read = Common.native_compress source, remaining_destination_buffer_length needs_more_destination = bytes_read < source.bytesize @destination_buffer << data [bytes_read, needs_more_destination] end |