Class: Codify::Encoders::ZlibEncoder
- Inherits:
-
AbstractEncoder
- Object
- AbstractEncoder
- Codify::Encoders::ZlibEncoder
- Defined in:
- lib/codify/encoders/zlib_encoder.rb
Instance Method Summary collapse
Methods inherited from AbstractEncoder
decode, #decodes?, #depends_on_record?, encode, #initialize, #record=
Constructor Details
This class inherits a constructor from Codify::Encoders::AbstractEncoder
Instance Method Details
#decode(data) ⇒ Object
18 19 20 21 |
# File 'lib/codify/encoders/zlib_encoder.rb', line 18 def decode data inflator = Zlib::Inflate.new inflator.inflate(data) end |
#encode(data) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/codify/encoders/zlib_encoder.rb', line 10 def encode data level = (:level) || Zlib::DEFAULT_COMPRESSION deflator = Zlib::Deflate.new(level) # deflator.set_dictionary(options[:dictionary]) if options.has_key? :dictionary deflator.deflate(data.to_s, Zlib::FINISH) end |