Class: Shhh::Data::Encoder

Inherits:
Object
  • Object
show all
Defined in:
lib/shhh/data/encoder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, compress) ⇒ Encoder


12
13
14
15
16
17
# File 'lib/shhh/data/encoder.rb', line 12

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

Instance Attribute Details

#dataObject

Returns the value of attribute data


10
11
12
# File 'lib/shhh/data/encoder.rb', line 10

def data
  @data
end

#data_encodedObject

Returns the value of attribute data_encoded


10
11
12
# File 'lib/shhh/data/encoder.rb', line 10

def data_encoded
  @data_encoded
end

Instance Method Details

#compression_levelObject


19
20
21
# File 'lib/shhh/data/encoder.rb', line 19

def compression_level
  Shhh::Configuration.config.compression_level
end