Class: ADSP::File

Inherits:
Object
  • Object
show all
Defined in:
lib/adsp/file.rb

Overview

ADSP::File class.

Direct Known Subclasses

Test::Mock::File

Constant Summary collapse

Option =

Current option class.

ADSP::Option
BUFFER_LENGTH_NAMES =

Current buffer length names. It is a part of compressor and decompressor options.

%i[source_buffer_length destination_buffer_length].freeze

Class Method Summary collapse

Class Method Details

.compress(source, destination, options = {}) ⇒ Object

Compresses data from source file path to destination file path. Option: :source_buffer_length source buffer length. Option: :destination_buffer_length destination buffer length.



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/adsp/file.rb', line 21

def self.compress(source, destination, options = {})
  Validation.validate_string source
  Validation.validate_string destination

  options = self::Option.get_compressor_options options, BUFFER_LENGTH_NAMES

  open_files source, destination do |source_io, destination_io|
    native_compress_io source_io, destination_io, options
  end

  nil
end

.decompress(source, destination, options = {}) ⇒ Object

Decompresses data from source file path to destination file path. Option: :source_buffer_length source buffer length. Option: :destination_buffer_length destination buffer length.



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/adsp/file.rb', line 46

def self.decompress(source, destination, options = {})
  Validation.validate_string source
  Validation.validate_string destination

  options = self::Option.get_decompressor_options options, BUFFER_LENGTH_NAMES

  open_files source, destination do |source_io, destination_io|
    native_decompress_io source_io, destination_io, options
  end

  nil
end

.native_compress_io(source_io, destination_io, options) ⇒ Object

Internal method for compressing data from source_io file to destination_io file.



37
38
39
# File 'lib/adsp/file.rb', line 37

def self.native_compress_io(source_io, destination_io, options)
  raise NotImplementedError
end

.native_decompress_io(source_io, destination_io, options) ⇒ Object

Internal method for decompressing data from source_io file to destination_io file.



62
63
64
# File 'lib/adsp/file.rb', line 62

def self.native_decompress_io(source_io, destination_io, options)
  raise NotImplementedError
end