Class: Omnizip::Implementations::Base::LZMA2EncoderBase Abstract
- Inherits:
-
Object
- Object
- Omnizip::Implementations::Base::LZMA2EncoderBase
- Defined in:
- lib/omnizip/implementations/base/lzma2_encoder_base.rb
Overview
Subclasses must implement #encode
Abstract base class for LZMA2 encoders.
This class defines the common interface and shared functionality for all LZMA2 encoder implementations (XZ Utils, 7-Zip, etc.).
LZMA2 is an improved version of LZMA that supports:
- Uncompressed chunks for incompressible data
- Dictionary/state resets for better compression
- Simpler chunk format
Subclasses must implement the #encode method.
Direct Known Subclasses
Constant Summary collapse
- UNCOMPRESSED_MAX =
Maximum uncompressed size per LZMA2 chunk (2MB)
1 << 21
- COMPRESSED_MAX =
Maximum compressed size per LZMA2 chunk (64KB)
1 << 16
Instance Attribute Summary collapse
-
#dict_size ⇒ Object
readonly
Returns the value of attribute dict_size.
-
#lc ⇒ Object
readonly
Returns the value of attribute lc.
-
#lp ⇒ Object
readonly
Returns the value of attribute lp.
-
#pb ⇒ Object
readonly
Returns the value of attribute pb.
Instance Method Summary collapse
-
#encode(data) ⇒ String
Encode data using LZMA2.
-
#implementation_name ⇒ Symbol
Get the implementation identifier.
-
#initialize(options = {}) ⇒ LZMA2EncoderBase
constructor
Initialize the LZMA2 encoder.
-
#standalone? ⇒ Boolean
Check if standalone mode is enabled.
Constructor Details
#initialize(options = {}) ⇒ LZMA2EncoderBase
Initialize the LZMA2 encoder.
55 56 57 58 59 60 61 62 63 |
# File 'lib/omnizip/implementations/base/lzma2_encoder_base.rb', line 55 def initialize( = {}) @dict_size = .fetch(:dict_size, 8 * 1024 * 1024) @lc = .fetch(:lc, 3) @lp = .fetch(:lp, 0) @pb = .fetch(:pb, 2) @standalone = .fetch(:standalone, true) validate_parameters! end |
Instance Attribute Details
#dict_size ⇒ Object (readonly)
Returns the value of attribute dict_size.
40 41 42 |
# File 'lib/omnizip/implementations/base/lzma2_encoder_base.rb', line 40 def dict_size @dict_size end |
#lc ⇒ Object (readonly)
Returns the value of attribute lc.
40 41 42 |
# File 'lib/omnizip/implementations/base/lzma2_encoder_base.rb', line 40 def lc @lc end |
#lp ⇒ Object (readonly)
Returns the value of attribute lp.
40 41 42 |
# File 'lib/omnizip/implementations/base/lzma2_encoder_base.rb', line 40 def lp @lp end |
#pb ⇒ Object (readonly)
Returns the value of attribute pb.
40 41 42 |
# File 'lib/omnizip/implementations/base/lzma2_encoder_base.rb', line 40 def pb @pb end |
Instance Method Details
#encode(data) ⇒ String
Encode data using LZMA2.
Subclasses must implement this method to provide the specific encoding logic for their implementation (XZ Utils, 7-Zip, etc.).
73 74 75 76 |
# File 'lib/omnizip/implementations/base/lzma2_encoder_base.rb', line 73 def encode(data) raise NotImplementedError, "#{self.class} must implement #encode" end |
#implementation_name ⇒ Symbol
Get the implementation identifier.
Subclasses must implement this to return a symbol identifying their implementation (e.g., :xz_utils, :seven_zip).
85 86 87 88 |
# File 'lib/omnizip/implementations/base/lzma2_encoder_base.rb', line 85 def implementation_name raise NotImplementedError, "#{self.class} must implement #implementation_name" end |
#standalone? ⇒ Boolean
Check if standalone mode is enabled.
93 94 95 |
# File 'lib/omnizip/implementations/base/lzma2_encoder_base.rb', line 93 def standalone? @standalone end |