Class: ADSP::Option

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

Overview

ADSP::Option class.

Constant Summary collapse

DEFAULT_BUFFER_LENGTH =

Current default buffer length. It will be used when buffer length option is not defined.

0

Class Method Summary collapse

Class Method Details

.get_compressor_options(options, buffer_length_names = []) ⇒ Object

Validates and processes default values for compressor options. buffer_length_names is an array of buffer length names (option names).



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/adsp/option.rb', line 15

def self.get_compressor_options(options, buffer_length_names = [])
  Validation.validate_hash options
  Validation.validate_array buffer_length_names

  buffer_length_names.each { |name| Validation.validate_symbol name }

  buffer_length_defaults = buffer_length_names.each_with_object({}) do |name, defaults|
    defaults[name] = DEFAULT_BUFFER_LENGTH
  end

  options = buffer_length_defaults.merge options

  buffer_length_names.each { |name| Validation.validate_not_negative_integer options[name] }

  options
end

.get_decompressor_options(options, buffer_length_names = []) ⇒ Object

Validates and processes default values for decompressor options. buffer_length_names is an array of buffer length names (option names).



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/adsp/option.rb', line 34

def self.get_decompressor_options(options, buffer_length_names = [])
  Validation.validate_hash options
  Validation.validate_array buffer_length_names

  buffer_length_names.each { |name| Validation.validate_symbol name }

  buffer_length_defaults = buffer_length_names.each_with_object({}) do |name, defaults|
    defaults[name] = DEFAULT_BUFFER_LENGTH
  end

  options = buffer_length_defaults.merge options

  buffer_length_names.each { |name| Validation.validate_not_negative_integer options[name] }

  options
end