Class: Secrets::Data::Encoder
- Inherits:
-
Object
- Object
- Secrets::Data::Encoder
- Defined in:
- lib/secrets/data/encoder.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#data_encoded ⇒ Object
Returns the value of attribute data_encoded.
Instance Method Summary collapse
- #compression_level ⇒ Object
-
#initialize(data, compress) ⇒ Encoder
constructor
A new instance of Encoder.
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
#data ⇒ Object
Returns the value of attribute data.
10 11 12 |
# File 'lib/secrets/data/encoder.rb', line 10 def data @data end |
#data_encoded ⇒ Object
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_level ⇒ Object
19 20 21 |
# File 'lib/secrets/data/encoder.rb', line 19 def compression_level Secrets::Configuration.config.compression_level end |