Class: Omnizip::Implementations::Base::LZMA2DecoderBase Abstract

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

Overview

This class is abstract.

Subclasses must implement #decode

Abstract base class for LZMA2 decoders.

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

Subclasses must implement the #decode method.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Initialize the LZMA2 decoder.

Parameters:

  • input (IO)

    Input stream of compressed data

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

    Decoding options

Options Hash (options):

  • :dict_size (Integer)

    Dictionary size (read from properties)



42
43
44
45
46
# File 'lib/omnizip/implementations/base/lzma2_decoder_base.rb', line 42

def initialize(input, options = {})
  @input = input
  # Dictionary size will be read from LZMA2 property byte by subclasses
  @dict_size = options.fetch(:dict_size, nil)
end

Instance Attribute Details

#dict_sizeObject (readonly)

Returns the value of attribute dict_size.



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

def dict_size
  @dict_size
end

Instance Method Details

#decode(output = nil) ⇒ void

This method returns an undefined value.

Decode LZMA2 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



56
57
58
59
# File 'lib/omnizip/implementations/base/lzma2_decoder_base.rb', line 56

def decode(output = nil)
  raise NotImplementedError,
        "#{self.class} must implement #decode"
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



68
69
70
71
# File 'lib/omnizip/implementations/base/lzma2_decoder_base.rb', line 68

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