Class: Zrip::BlockCodec

Inherits:
Object
  • Object
show all
Defined in:
lib/zrip/block_codec.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(dict: nil, level: DEFAULT_LEVEL) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/zrip/block_codec.rb', line 7

def self.new(dict: nil, level: DEFAULT_LEVEL)
  case dict
  when nil
    _native_new(nil, 0, Integer(level))
  when Dictionary
    _native_new(dict.bytes, dict.id, Integer(level))
  when String
    d = Dictionary.new(bytes: dict)
    _native_new(d.bytes, d.id, Integer(level))
  else
    raise TypeError, "expected Zrip::Dictionary, String, or nil; got #{dict.class}"
  end
end

Instance Method Details

#decompress(bytes, max_output_size: nil) ⇒ Object



22
23
24
# File 'lib/zrip/block_codec.rb', line 22

def decompress(bytes, max_output_size: nil)
  _native_decompress(bytes, Integer(max_output_size || 0))
end