Class: Omnizip::Formats::Rar5::Decompressor

Inherits:
Omnizip::Formats::Rar::RarFormatBase show all
Defined in:
lib/omnizip/formats/rar5/decompressor.rb

Overview

RAR v5 decompressor

Decompresses data using RAR v5 decompression algorithms. This implementation uses DEFLATE as a compatible fallback for demonstration purposes. Full RAR5 decompression requires proprietary algorithms.

Examples:

Decompressing data

decompressor = Rar5::Decompressor.new
original = decompressor.decompress(compressed, method: :normal)

Instance Attribute Summary

Attributes inherited from Omnizip::Formats::Rar::RarFormatBase

#spec, #version

Instance Method Summary collapse

Methods inherited from Omnizip::Formats::Rar::RarFormatBase

#block_type_code, #block_type_name, #compress, #compression_method_code, #compression_method_name, #dictionary_size_code, #encryption_algorithm, #read_archive, #supports_feature?, #verify_magic_bytes, #write_archive

Constructor Details

#initializeDecompressor

Initialize a RAR v5 decompressor



20
21
22
# File 'lib/omnizip/formats/rar5/decompressor.rb', line 20

def initialize
  super("rar5")
end

Instance Method Details

#decompress(data, method: :normal, **_options) ⇒ String

Decompress data using RAR v5 methods

Parameters:

  • data (String)

    The compressed data

  • method (Symbol) (defaults to: :normal)

    The compression method

  • options (Hash)

    Decompression options

Returns:

  • (String)

    The decompressed data



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/omnizip/formats/rar5/decompressor.rb', line 30

def decompress(data, method: :normal, **_options)
  case method
  when :store
    decompress_store(data)
  when :fastest, :fast, :normal, :good, :best
    decompress_deflate(data)
  else
    raise FormatError,
          "Unsupported decompression method: #{method}"
  end
end