Module: ZstdRuby
- Defined in:
- lib/zstd_ruby.rb
Constant Summary collapse
- DEFAULT_COMPRESSION_LEVEL =
Default compression level
3- MIN_COMPRESSION_LEVEL =
Valid compression level range
1- MAX_COMPRESSION_LEVEL =
22
Class Method Summary collapse
-
.compress_file(input_path, output_path, level: DEFAULT_COMPRESSION_LEVEL) ⇒ Boolean
Compress a file using zstd compression.
-
.decompress_file(input_path, output_path) ⇒ Boolean
Decompress a zstd-compressed file.
Class Method Details
.compress_file(input_path, output_path, level: DEFAULT_COMPRESSION_LEVEL) ⇒ Boolean
Compress a file using zstd compression
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/zstd_ruby.rb', line 29 def compress_file(input_path, output_path, level: DEFAULT_COMPRESSION_LEVEL) # Validate compression level unless level.is_a?(Integer) raise ArgumentError, "Compression level must be an integer" end unless level >= MIN_COMPRESSION_LEVEL && level <= MAX_COMPRESSION_LEVEL raise ArgumentError, "Compression level must be between #{MIN_COMPRESSION_LEVEL} and #{MAX_COMPRESSION_LEVEL}" end # Convert paths to strings input_path = input_path.to_s output_path = output_path.to_s # Call native extension ZstdRubyNative.compress_file_native(input_path, output_path, level) end |
.decompress_file(input_path, output_path) ⇒ Boolean
Decompress a zstd-compressed file
59 60 61 62 63 64 65 66 |
# File 'lib/zstd_ruby.rb', line 59 def decompress_file(input_path, output_path) # Convert paths to strings input_path = input_path.to_s output_path = output_path.to_s # Call native extension ZstdRubyNative.decompress_file_native(input_path, output_path) end |