Module: Zstandard

Defined in:
lib/zstandard.rb,
lib/zstandard/api.rb,
lib/zstandard/config.rb,
lib/zstandard/version.rb,
lib/zstandard/ffi_bindings.rb

Defined Under Namespace

Modules: API, Config, FFIBindings Classes: DecompressedSizeUnknownError, Error, LibraryVersionNotSupportedError

Constant Summary collapse

VERSION =
"0.1.3"

Class Method Summary collapse

Class Method Details

.deflate(string, level = nil) ⇒ Object


10
11
12
# File 'lib/zstandard.rb', line 10

def self.deflate(string, level = nil)
  API.simple_compress(string, level: level)
end

.inflate(string) ⇒ Object


14
15
16
17
18
19
20
21
22
# File 'lib/zstandard.rb', line 14

def self.inflate(string)
  decompressed_size = API.decompressed_size(string)

  if decompressed_size > 0 && decompressed_size <= Config::MAX_SIMPLE_DECOMPRESS_SIZE
    API.simple_decompress(string)
  else
    API.streaming_decompress(string)
  end
end