Class: Sym::Data::Decoder

Inherits:
Object show all
Defined in:
lib/sym/data/decoder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data_encoded, compress) ⇒ Decoder

Returns a new instance of Decoder.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/sym/data/decoder.rb', line 10

def initialize(data_encoded, compress)
  self.data_encoded = data_encoded
  self.data         = begin
    Base64.urlsafe_decode64(data_encoded)
  rescue
    data_encoded
  end

  if compress.nil? || compress # auto-guess
    self.data = begin
      Zlib::Inflate.inflate(data)
    rescue Zlib::Error => e
      data
    end
  end
  self.data = Marshal.load(data)
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



8
9
10
# File 'lib/sym/data/decoder.rb', line 8

def data
  @data
end

#data_encodedObject

Returns the value of attribute data_encoded.



8
9
10
# File 'lib/sym/data/decoder.rb', line 8

def data_encoded
  @data_encoded
end