Class: Omnizip::Implementations::Base::LZMADecoderBase Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/omnizip/implementations/base/lzma_decoder_base.rb

Overview

This class is abstract.

Subclasses must implement #decode_stream

Abstract base class for LZMA decoders.

This class defines the common interface and shared functionality for all LZMA decoder implementations (XZ Utils, 7-Zip SDK, etc.).

Subclasses must implement the #decode_stream method.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, options = {}) ⇒ LZMADecoderBase

Initialize the LZMA decoder.

Parameters:

  • input (IO)

    Input stream of compressed data

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

    Decoding options

Options Hash (options):

  • :lc (Integer)

    Literal context bits (read from header)

  • :lp (Integer)

    Literal position bits (read from header)

  • :pb (Integer)

    Position bits (read from header)

  • :dict_size (Integer)

    Dictionary size (read from header)

  • :uncompressed_size (Integer)

    Uncompressed size



46
47
48
49
50
51
52
53
54
# File 'lib/omnizip/implementations/base/lzma_decoder_base.rb', line 46

def initialize(input, options = {})
  @input = input
  # Parameters will be read from LZMA header by subclasses
  @lc = options.fetch(:lc, nil)
  @lp = options.fetch(:lp, nil)
  @pb = options.fetch(:pb, nil)
  @dict_size = options.fetch(:dict_size, nil)
  @uncompressed_size = options.fetch(:uncompressed_size, nil)
end

Instance Attribute Details

#dict_sizeObject (readonly)

Returns the value of attribute dict_size.



35
36
37
# File 'lib/omnizip/implementations/base/lzma_decoder_base.rb', line 35

def dict_size
  @dict_size
end

#inputObject (readonly)

Returns the value of attribute input.



35
36
37
# File 'lib/omnizip/implementations/base/lzma_decoder_base.rb', line 35

def input
  @input
end

#lcObject (readonly)

Returns the value of attribute lc.



35
36
37
# File 'lib/omnizip/implementations/base/lzma_decoder_base.rb', line 35

def lc
  @lc
end

#lpObject (readonly)

Returns the value of attribute lp.



35
36
37
# File 'lib/omnizip/implementations/base/lzma_decoder_base.rb', line 35

def lp
  @lp
end

#pbObject (readonly)

Returns the value of attribute pb.



35
36
37
# File 'lib/omnizip/implementations/base/lzma_decoder_base.rb', line 35

def pb
  @pb
end

#uncompressed_sizeObject (readonly)

Returns the value of attribute uncompressed_size.



35
36
37
# File 'lib/omnizip/implementations/base/lzma_decoder_base.rb', line 35

def uncompressed_size
  @uncompressed_size
end

Instance Method Details

#decode_stream(output = nil) ⇒ void

This method returns an undefined value.

Decode a stream of compressed data.

Subclasses must implement this method to provide the specific decoding logic for their implementation (XZ Utils, 7-Zip, etc.).

Parameters:

  • output (IO) (defaults to: nil)

    Output stream for decompressed data

Raises:

  • (NotImplementedError)

    Always raised in base class



64
65
66
67
# File 'lib/omnizip/implementations/base/lzma_decoder_base.rb', line 64

def decode_stream(output = nil)
  raise NotImplementedError,
        "#{self.class} must implement #decode_stream"
end

#implementation_nameSymbol

Get the implementation identifier.

Subclasses must implement this to return a symbol identifying their implementation (e.g., :xz_utils, :seven_zip).

Returns:

  • (Symbol)

    Implementation identifier

Raises:

  • (NotImplementedError)

    Always raised in base class



76
77
78
79
# File 'lib/omnizip/implementations/base/lzma_decoder_base.rb', line 76

def implementation_name
  raise NotImplementedError,
        "#{self.class} must implement #implementation_name"
end