Class: Omnizip::Algorithms::LZMA::OptimalEncoder

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

Overview

Optimal encoder - chooses best encoding Ported from lzma_encoder_optimum_fast.c

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mode: :fast) ⇒ OptimalEncoder

Returns a new instance of OptimalEncoder.



11
12
13
# File 'lib/omnizip/algorithms/lzma/optimal_encoder.rb', line 11

def initialize(mode: :fast)
  @mode = mode
end

Instance Attribute Details

#modeObject (readonly)

Returns the value of attribute mode.



9
10
11
# File 'lib/omnizip/algorithms/lzma/optimal_encoder.rb', line 9

def mode
  @mode
end

Instance Method Details

#find_optimal(position, match_finder, state, reps, models) ⇒ Object

Find optimal encoding for current position



16
17
18
19
20
21
22
23
# File 'lib/omnizip/algorithms/lzma/optimal_encoder.rb', line 16

def find_optimal(position, match_finder, state, reps, models)
  case @mode
  when :fast
    optimum_fast(position, match_finder, state, reps, models)
  else
    raise ArgumentError, "Unknown mode: #{@mode}"
  end
end