Class: Omnizip::Formats::Rar::CompressionMethodRegistry
- Inherits:
-
Object
- Object
- Omnizip::Formats::Rar::CompressionMethodRegistry
- Defined in:
- lib/omnizip/formats/rar/compression_method_registry.rb
Overview
Registry for RAR compression methods
This class manages the registration and retrieval of compression methods for RAR archives. It follows the Registry pattern to allow dynamic addition of compression methods without modifying core code.
Class Method Summary collapse
-
.clear ⇒ void
Clear all registered methods (primarily for testing).
-
.compressor(name) ⇒ Class
Get a compressor for a method.
-
.decompressor(name) ⇒ Class
Get a decompressor for a method.
-
.method_for_version(version, level) ⇒ Symbol
Get a compression method for a RAR version and level.
-
.register(name, compressor, decompressor) ⇒ void
Register a compression method.
-
.registered?(name) ⇒ Boolean
Check if a method is registered.
-
.registered_methods ⇒ Array<Symbol>
Get all registered method names.
Class Method Details
.clear ⇒ void
This method returns an undefined value.
Clear all registered methods (primarily for testing)
80 81 82 |
# File 'lib/omnizip/formats/rar/compression_method_registry.rb', line 80 def clear @methods = {} end |
.compressor(name) ⇒ Class
Get a compressor for a method
41 42 43 44 45 46 47 |
# File 'lib/omnizip/formats/rar/compression_method_registry.rb', line 41 def compressor(name) method_data = methods[name] return method_data[:compressor] if method_data raise Error::FormatError, "No compressor registered for method: #{name}" end |
.decompressor(name) ⇒ Class
Get a decompressor for a method
54 55 56 57 58 59 60 |
# File 'lib/omnizip/formats/rar/compression_method_registry.rb', line 54 def decompressor(name) method_data = methods[name] return method_data[:decompressor] if method_data raise Error::FormatError, "No decompressor registered for method: #{name}" end |
.method_for_version(version, level) ⇒ Symbol
Get a compression method for a RAR version and level
89 90 91 92 |
# File 'lib/omnizip/formats/rar/compression_method_registry.rb', line 89 def method_for_version(version, level) prefix = version.start_with?("5") ? "rar5" : "rar3" :"#{prefix}_#{level}" end |
.register(name, compressor, decompressor) ⇒ void
This method returns an undefined value.
Register a compression method
29 30 31 32 33 34 |
# File 'lib/omnizip/formats/rar/compression_method_registry.rb', line 29 def register(name, compressor, decompressor) methods[name] = { compressor: compressor, decompressor: decompressor, } end |
.registered?(name) ⇒ Boolean
Check if a method is registered
66 67 68 |
# File 'lib/omnizip/formats/rar/compression_method_registry.rb', line 66 def registered?(name) methods.key?(name) end |
.registered_methods ⇒ Array<Symbol>
Get all registered method names
73 74 75 |
# File 'lib/omnizip/formats/rar/compression_method_registry.rb', line 73 def registered_methods methods.keys end |