Class: CompareCompressors::Compressor
- Inherits:
-
Object
- Object
- CompareCompressors::Compressor
- Defined in:
- lib/compare_compressors/compressor.rb
Overview
Base class for compressors. Subclasses provide compressor-specific configuration and logic.
Direct Known Subclasses
BrotliCompressor, Bzip2Compressor, GzipCompressor, SevenZipCompressor, XzCompressor, ZstdCompressor
Instance Method Summary collapse
-
#compression_command ⇒ Array<String>
abstract
Command to run the compressor.
-
#decompression_command ⇒ Array<String>
abstract
Command to run the compressor in decompress mode.
-
#display_name ⇒ String
Display name (need not be safe to intern as a symbol).
-
#evaluate(target, work_target, level) ⇒ Result
Run the compressor at the given level on the given target and measure its running time and memory usage.
-
#extension ⇒ String
abstract
Extension added to the compressed file.
-
#levels ⇒ Array<Integer>
abstract
The levels supported by the compressor.
-
#name ⇒ String
abstract
Name that can be a ruby symbol.
-
#version ⇒ String?
abstract
Version string (for information only).
Instance Method Details
#compression_command ⇒ Array<String>
Returns command to run the compressor.
77 78 79 |
# File 'lib/compare_compressors/compressor.rb', line 77 def compression_command raise NotImplementedError end |
#decompression_command ⇒ Array<String>
Returns command to run the compressor in decompress mode.
85 86 87 |
# File 'lib/compare_compressors/compressor.rb', line 85 def decompression_command raise NotImplementedError end |
#display_name ⇒ String
Returns display name (need not be safe to intern as a symbol).
69 70 71 |
# File 'lib/compare_compressors/compressor.rb', line 69 def display_name name end |
#evaluate(target, work_target, level) ⇒ Result
Run the compressor at the given level on the given target and measure its running time and memory usage.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/compare_compressors/compressor.rb', line 21 def evaluate(target, work_target, level) compression_times = time(compression_command(work_target, level)) size = output_size(work_target) remove_if_exists(work_target) decompression_times = time(decompression_command(work_target)) remove_if_exists(output_name(work_target)) Result.new( target, name, level, *compression_times, size, *decompression_times ) end |
#extension ⇒ String
Returns extension added to the compressed file.
46 47 48 |
# File 'lib/compare_compressors/compressor.rb', line 46 def extension raise NotImplementedError end |
#levels ⇒ Array<Integer>
Returns the levels supported by the compressor.
54 55 56 |
# File 'lib/compare_compressors/compressor.rb', line 54 def levels raise NotImplementedError end |
#name ⇒ String
Returns name that can be a ruby symbol.
38 39 40 |
# File 'lib/compare_compressors/compressor.rb', line 38 def name raise NotImplementedError end |
#version ⇒ String?
Returns version string (for information only).
62 63 64 |
# File 'lib/compare_compressors/compressor.rb', line 62 def version nil end |