Class: Omnizip::Algorithms::Zstandard::Encoder
- Inherits:
-
Object
- Object
- Omnizip::Algorithms::Zstandard::Encoder
- Includes:
- Constants
- Defined in:
- lib/omnizip/algorithms/zstandard/encoder.rb
Overview
Pure Ruby Zstandard encoder (RFC 8878)
Encodes data using Zstandard format. Supports raw blocks and Huffman-compressed literals.
Constant Summary
Constants included from Constants
Constants::BLOCK_HEADER_SIZE, Constants::BLOCK_MAX_SIZE, Constants::BLOCK_TYPE_COMPRESSED, Constants::BLOCK_TYPE_RAW, Constants::BLOCK_TYPE_RESERVED, Constants::BLOCK_TYPE_RLE, Constants::BUFFER_SIZE, Constants::DEFAULT_LEVEL, Constants::DEFAULT_REPEAT_OFFSETS, Constants::FSE_MAX_ACCURACY_LOG, Constants::FSE_MIN_ACCURACY_LOG, Constants::HUFFMAN_MAX_BITS, Constants::HUFFMAN_MAX_CODE_LENGTH, Constants::HUFFMAN_MAX_LOG, Constants::HUFFMAN_STANDARD_TABLE_SIZE, Constants::LITERALS_BLOCK_COMPRESSED, Constants::LITERALS_BLOCK_RAW, Constants::LITERALS_BLOCK_RLE, Constants::LITERALS_BLOCK_TREELESS, Constants::LITERALS_LENGTH_ACCURACY_LOG, Constants::LITERAL_LENGTH_TABLE, Constants::MAGIC_BYTES, Constants::MAGIC_NUMBER, Constants::MATCH_LENGTH_ACCURACY_LOG, Constants::MATCH_LENGTH_TABLE, Constants::MAX_LEVEL, Constants::MIN_LEVEL, Constants::MODE_FSE, Constants::MODE_PREDEFINED, Constants::MODE_REPEAT, Constants::MODE_RLE, Constants::OFFSET_ACCURACY_LOG, Constants::PREDEFINED_LL_DISTRIBUTION, Constants::PREDEFINED_ML_DISTRIBUTION, Constants::PREDEFINED_OFFSET_DISTRIBUTION, Constants::REPEAT_OFFSET_1, Constants::REPEAT_OFFSET_2, Constants::REPEAT_OFFSET_3, Constants::SKIPPABLE_MAGIC_BASE, Constants::SKIPPABLE_MAGIC_MASK, Constants::WINDOW_LOG_MAX, Constants::WINDOW_LOG_MIN
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#output_stream ⇒ Object
readonly
Returns the value of attribute output_stream.
Instance Method Summary collapse
-
#encode_stream(data) ⇒ void
Encode data stream.
-
#initialize(output_stream, options = {}) ⇒ Encoder
constructor
Initialize encoder.
Constructor Details
#initialize(output_stream, options = {}) ⇒ Encoder
Initialize encoder
41 42 43 44 45 46 |
# File 'lib/omnizip/algorithms/zstandard/encoder.rb', line 41 def initialize(output_stream, = {}) @output_stream = output_stream @options = @level = [:level] || DEFAULT_LEVEL @use_compression = .fetch(:use_compression, true) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
33 34 35 |
# File 'lib/omnizip/algorithms/zstandard/encoder.rb', line 33 def @options end |
#output_stream ⇒ Object (readonly)
Returns the value of attribute output_stream.
33 34 35 |
# File 'lib/omnizip/algorithms/zstandard/encoder.rb', line 33 def output_stream @output_stream end |
Instance Method Details
#encode_stream(data) ⇒ void
This method returns an undefined value.
Encode data stream
52 53 54 55 |
# File 'lib/omnizip/algorithms/zstandard/encoder.rb', line 52 def encode_stream(data) # Write Zstandard frame write_frame(data) end |