Sha256: 2212c39f54a0579755630f2c8f11c2dbea4c4ad77d48340a511532c49d05db68

Contents?: true

Size: 569 Bytes

Versions: 10

Compression:

Stored size: 569 Bytes

Contents

require 'base64'
require 'zlib'

require 'shhh/errors'
require 'shhh/configuration'

module Shhh
  module Data
    class Encoder
      attr_accessor :data, :data_encoded

      def initialize(data, compress)
        self.data         = data
        self.data_encoded = Marshal.dump(data)
        self.data_encoded = Zlib::Deflate.deflate(data_encoded, compression_level) if compress
        self.data_encoded = Base64.urlsafe_encode64(data_encoded)
      end

      def compression_level
        Shhh::Configuration.config.compression_level
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
shhh-1.7.0 lib/shhh/data/encoder.rb
shhh-1.6.5 lib/shhh/data/encoder.rb
shhh-1.6.4 lib/shhh/data/encoder.rb
shhh-1.6.3 lib/shhh/data/encoder.rb
shhh-1.6.2 lib/shhh/data/encoder.rb
shhh-1.6.1 lib/shhh/data/encoder.rb
shhh-1.5.4 lib/shhh/data/encoder.rb
shhh-1.4.1 lib/shhh/data/encoder.rb
shhh-1.4.0 lib/shhh/data/encoder.rb
shhh-1.3.0 lib/shhh/data/encoder.rb