Module: LZWS::Option
- Defined in:
- lib/lzws/option.rb
Overview
LZWS::Option module.
Constant Summary collapse
- DEFAULT_BUFFER_LENGTH =
Current default buffer length.
0
- COMPRESSOR_DEFAULTS =
Current compressor defaults.
{ # Enables global VM lock where possible. :gvl => false, # Max code bit length. :max_code_bit_length => nil, # Disables magic header. :without_magic_header => nil, # Enables block mode. :block_mode => nil, # Enables most significant bit mode. :msb => nil, # Enables unaligned bit groups. :unaligned_bit_groups => nil, # Disables lzws library logging. :quiet => nil } .freeze
- DECOMPRESSOR_DEFAULTS =
Current decompressor defaults.
{ # Enables global VM lock where possible. :gvl => false, # Disables magic header. :without_magic_header => nil, # Enables most significant bit mode. :msb => nil, # Enables unaligned bit groups. :unaligned_bit_groups => nil, # Disables lzws library logging. :quiet => nil } .freeze
Class Method Summary collapse
-
.get_compressor_options(options, buffer_length_names) ⇒ Object
Processes compressor
options
andbuffer_length_names
. -
.get_decompressor_options(options, buffer_length_names) ⇒ Object
Processes decompressor
options
andbuffer_length_names
.
Class Method Details
.get_compressor_options(options, buffer_length_names) ⇒ Object
Processes compressor options
and buffer_length_names
. Option: :source_buffer_length
source buffer length. Option: :destination_buffer_length
destination buffer length. Option: :gvl
enables global VM lock where possible. Option: :max_code_bit_length
max code bit length. Option: :block_mode
enables block mode. Option: :without_magic_header
disables magic header. Option: :msb
enables most significant bit mode. Option: :unaligned_bit_groups
enables unaligned bit groups. Option: :quiet
disables lzws library logging. Returns processed compressor options.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/lzws/option.rb', line 60 def self.(, buffer_length_names) Validation.validate_hash buffer_length_defaults = buffer_length_names.each_with_object({}) do |name, defaults| defaults[name] = DEFAULT_BUFFER_LENGTH end = COMPRESSOR_DEFAULTS.merge(buffer_length_defaults).merge buffer_length_names.each { |name| Validation.validate_not_negative_integer [name] } Validation.validate_bool [:gvl] max_code_bit_length = [:max_code_bit_length] unless max_code_bit_length.nil? 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 end without_magic_header = [:without_magic_header] Validation.validate_bool without_magic_header unless without_magic_header.nil? block_mode = [:block_mode] Validation.validate_bool block_mode unless block_mode.nil? msb = [:msb] Validation.validate_bool msb unless msb.nil? unaligned_bit_groups = [:unaligned_bit_groups] Validation.validate_bool unaligned_bit_groups unless unaligned_bit_groups.nil? quiet = [:quiet] Validation.validate_bool quiet unless quiet.nil? end |
.get_decompressor_options(options, buffer_length_names) ⇒ Object
Processes decompressor options
and buffer_length_names
. Option: :source_buffer_length
source buffer length. Option: :destination_buffer_length
destination buffer length. Option: :gvl
enables global VM lock where possible. Option: :without_magic_header
disables magic header. Option: :msb
enables most significant bit mode. Option: :unaligned_bit_groups
enables unaligned bit groups. Option: :quiet
disables lzws library logging. Returns processed decompressor options.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/lzws/option.rb', line 107 def self.(, buffer_length_names) Validation.validate_hash buffer_length_defaults = buffer_length_names.each_with_object({}) do |name, defaults| defaults[name] = DEFAULT_BUFFER_LENGTH end = DECOMPRESSOR_DEFAULTS.merge(buffer_length_defaults).merge buffer_length_names.each { |name| Validation.validate_not_negative_integer [name] } Validation.validate_bool [:gvl] without_magic_header = [:without_magic_header] Validation.validate_bool without_magic_header unless without_magic_header.nil? msb = [:msb] Validation.validate_bool msb unless msb.nil? unaligned_bit_groups = [:unaligned_bit_groups] Validation.validate_bool unaligned_bit_groups unless unaligned_bit_groups.nil? quiet = [:quiet] Validation.validate_bool quiet unless quiet.nil? end |