Sha256: 6cc21ae5c017cc23f32a6f943e8816f5b50fef2da0b117ed6f5f2659c6a5547b

Contents?: true

Size: 565 Bytes

Versions: 28

Compression:

Stored size: 565 Bytes

Contents

require 'base64'
require 'zlib'

require 'sym/errors'
require 'sym/configuration'

module Sym
  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
        Sym::Configuration.config.compression_level
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
sym-2.2.0 lib/sym/data/encoder.rb
sym-2.1.2 lib/sym/data/encoder.rb
sym-2.1.1 lib/sym/data/encoder.rb
sym-2.1.0 lib/sym/data/encoder.rb
sym-2.0.3 lib/sym/data/encoder.rb
sym-2.0.2 lib/sym/data/encoder.rb
sym-2.0.1 lib/sym/data/encoder.rb
sym-2.0.0 lib/sym/data/encoder.rb