Class: Omnizip::Algorithms::LZMA::MatchFinderFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/omnizip/algorithms/lzma/match_finder_factory.rb

Overview

Factory for creating Match Finder instances

This factory implements the Factory pattern to create different match finder implementations based on configuration. It provides a clean separation between the configuration (what) and the implementation (how).

Examples:

Creating an SDK-compatible match finder

config = MatchFinderConfig.sdk_config(dict_size: 65536, level: 5)
finder = MatchFinderFactory.create(config)

Creating a simplified match finder

config = MatchFinderConfig.simplified_config(dict_size: 65536)
finder = MatchFinderFactory.create(config)

Class Method Summary collapse

Class Method Details

.create(config) ⇒ MatchFinder, Implementations::SevenZip::LZMA::MatchFinder

Create a match finder instance based on configuration

Parameters:

Returns:

Raises:

  • (ArgumentError)

    if configuration is invalid



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/omnizip/algorithms/lzma/match_finder_factory.rb', line 46

def self.create(config)
  config.validate!

  case config.mode
  when "sdk"
    Implementations::SevenZip::LZMA::MatchFinder.new(config)
  when "simplified"
    # Use simplified MatchFinder implementation
    MatchFinder.new(config.window_size, config.max_match_length)
  else
    raise ArgumentError, "Unknown match finder mode: #{config.mode}"
  end
end

.from_options(options = {}) ⇒ MatchFinder, Implementations::SevenZip::LZMA::MatchFinder

Create match finder from options hash (convenience method)

Parameters:

  • options (Hash) (defaults to: {})

    Options hash

Options Hash (options):

  • :sdk_compatible (Boolean)

    Use SDK mode

  • :dict_size (Integer)

    Dictionary size

  • :level (Integer)

    Compression level

Returns:



67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/omnizip/algorithms/lzma/match_finder_factory.rb', line 67

def self.from_options(options = {})
  config = if options[:sdk_compatible]
             MatchFinderConfig.sdk_config(
               dict_size: options[:dict_size] || 65536,
               level: options[:level] || 5,
             )
           else
             MatchFinderConfig.simplified_config(
               dict_size: options[:dict_size] || 65536,
             )
           end

  create(config)
end