module BZS::String::Option
BZS::Option
module.
Constants
- COMPRESSOR_DEFAULTS
Current compressor defaults.
- DECOMPRESSOR_DEFAULTS
Current decompressor defaults.
- DEFAULT_BUFFER_LENGTH
Current default buffer length.
Public Class Methods
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: :block_size
block size to be used for compression. Option: :work_factor
controls threshold for switching from standard to fallback algorithm. Option: :quiet
disables bzip2 library logging. Returns processed compressor options.
# File lib/bzs/option.rb, line 47 def self.get_compressor_options(options, buffer_length_names) Validation.validate_hash options buffer_length_defaults = buffer_length_names.each_with_object({}) do |name, defaults| defaults[name] = DEFAULT_BUFFER_LENGTH end options = COMPRESSOR_DEFAULTS.merge(buffer_length_defaults).merge options buffer_length_names.each { |name| Validation.validate_not_negative_integer options[name] } Validation.validate_bool options[:gvl] block_size = options[:block_size] Validation.validate_not_negative_integer block_size unless block_size.nil? work_factor = options[:work_factor] Validation.validate_not_negative_integer work_factor unless work_factor.nil? quiet = options[:quiet] Validation.validate_bool quiet unless quiet.nil? options end
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: :small
enables alternative decompression algorithm with less memory. Option: :quiet
disables bzip2 library logging. Returns processed decompressor options.
# File lib/bzs/option.rb, line 79 def self.get_decompressor_options(options, buffer_length_names) Validation.validate_hash options buffer_length_defaults = buffer_length_names.each_with_object({}) do |name, defaults| defaults[name] = DEFAULT_BUFFER_LENGTH end options = DECOMPRESSOR_DEFAULTS.merge(buffer_length_defaults).merge options buffer_length_names.each { |name| Validation.validate_not_negative_integer options[name] } Validation.validate_bool options[:gvl] small = options[:small] Validation.validate_bool small unless small.nil? quiet = options[:quiet] Validation.validate_bool quiet unless quiet.nil? options end