Module: LZWS::Option
- Defined in:
- lib/lzws/option.rb
Constant Summary collapse
- DEFAULT_BUFFER_LENGTH =
Default options will be compatible with UNIX compress.
0- LOWEST_MAX_CODE_BIT_LENGTH =
9- BIGGEST_MAX_CODE_BIT_LENGTH =
16- DECOMPRESSOR_DEFAULTS =
{ :without_magic_header => false, :msb => false, :unaligned_bit_groups => false, :quiet => false } .freeze
- COMPRESSOR_DEFAULTS =
DECOMPRESSOR_DEFAULTS.merge( :max_code_bit_length => BIGGEST_MAX_CODE_BIT_LENGTH, :block_mode => true ) .freeze
Class Method Summary collapse
- .get_compressor_options(options, buffer_length_names) ⇒ Object
- .get_decompressor_options(options, buffer_length_names) ⇒ Object
Class Method Details
.get_compressor_options(options, buffer_length_names) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/lzws/option.rb', line 31 def self.(, buffer_length_names) Validation.validate_hash buffer_length_defaults = buffer_length_names.each_with_object({}) { |name, defaults| defaults[name] = DEFAULT_BUFFER_LENGTH } = COMPRESSOR_DEFAULTS.merge(buffer_length_defaults).merge buffer_length_names.each { |name| Validation.validate_not_negative_integer [name] } max_code_bit_length = [:max_code_bit_length] Validation.validate_positive_integer max_code_bit_length raise ValidateError, "invalid max code bit length" if max_code_bit_length < LOWEST_MAX_CODE_BIT_LENGTH || max_code_bit_length > BIGGEST_MAX_CODE_BIT_LENGTH Validation.validate_bool [:without_magic_header] Validation.validate_bool [:block_mode] Validation.validate_bool [:msb] Validation.validate_bool [:unaligned_bit_groups] Validation.validate_bool [:quiet] end |
.get_decompressor_options(options, buffer_length_names) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/lzws/option.rb', line 54 def self.(, buffer_length_names) Validation.validate_hash buffer_length_defaults = buffer_length_names.each_with_object({}) { |name, defaults| defaults[name] = DEFAULT_BUFFER_LENGTH } = DECOMPRESSOR_DEFAULTS.merge(buffer_length_defaults).merge buffer_length_names.each { |name| Validation.validate_not_negative_integer [name] } Validation.validate_bool [:without_magic_header] Validation.validate_bool [:msb] Validation.validate_bool [:unaligned_bit_groups] Validation.validate_bool [:quiet] end |