Class: ADSP::Test::Mock::String

Inherits:
String
  • Object
show all
Defined in:
lib/adsp/test/mock/string.rb

Overview

ADSP::Test::Mock::String class.

Constant Summary

Constants inherited from String

String::BUFFER_LENGTH_NAMES, String::Option

Class Method Summary collapse

Methods inherited from String

compress, decompress

Class Method Details

.native_compress_string(source, options) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/adsp/test/mock/string.rb', line 13

def self.native_compress_string(source, options)
  destination_buffer_length = options[:destination_buffer_length]
  result                    = "".b

  loop do
    data, bytes_read = Common.native_compress source, destination_buffer_length
    source = source.byteslice bytes_read, source.bytesize - bytes_read
    result << data

    break if source.bytesize.zero?
  end

  result
end

.native_decompress_string(source, options) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/adsp/test/mock/string.rb', line 28

def self.native_decompress_string(source, options)
  destination_buffer_length = options[:destination_buffer_length]
  result                    = "".b

  loop do
    data, bytes_read = Common.native_decompress source, destination_buffer_length
    source = source.byteslice bytes_read, source.bytesize - bytes_read
    result << data

    break if source.bytesize.zero?
  end

  result
end