Class: Secrets::Data::Encoder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, compress) ⇒ Encoder

Returns a new instance of Encoder.



12
13
14
15
16
17
# File 'lib/secrets/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/secrets/data/encoder.rb', line 10

def data
  @data
end

#data_encodedObject

Returns the value of attribute data_encoded.



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

def data_encoded
  @data_encoded
end

Instance Method Details

#compression_levelObject



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

def compression_level
  Secrets::Configuration.config.compression_level
end