Class: Vedeu::Templating::Decoder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/templating/decoder.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Converts an encoded string back into an object or collection of objects.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Vedeu::Templating::Decoder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Vedeu::Templating::Decoder.

Parameters:

  • data (String)


24
25
26
# File 'lib/vedeu/templating/decoder.rb', line 24

def initialize(data)
  @data = data
end

Instance Attribute Details

#dataString (readonly, protected)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


40
41
42
# File 'lib/vedeu/templating/decoder.rb', line 40

def data
  @data
end

Class Method Details

.process(data) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • data (String)

Returns:

  • (Object)


16
17
18
# File 'lib/vedeu/templating/decoder.rb', line 16

def self.process(data)
  new(data).process
end

Instance Method Details

#decode64String (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Decode the Base64 string into a compressed, marshalled object or objects.

Returns:

  • (String)


63
64
65
# File 'lib/vedeu/templating/decoder.rb', line 63

def decode64
  Base64.strict_decode64(unwrap)
end

#decompressString (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Decompress the marshalled object or objects.

Returns:

  • (String)


55
56
57
# File 'lib/vedeu/templating/decoder.rb', line 55

def decompress
  Zlib::Inflate.inflate(decode64)
end

#demarshalObject (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Convert the marshalled object or objects back into an object(s).

Returns:

  • (Object)


48
49
50
# File 'lib/vedeu/templating/decoder.rb', line 48

def demarshal
  Marshal.load(decompress)
end

#processObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Converts an encoded string back into an object or collection of objects.

Returns:

  • (Object)


32
33
34
# File 'lib/vedeu/templating/decoder.rb', line 32

def process
  demarshal
end

#unwrapString (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Removes delimiters from the start and end of the data.

Returns:

  • (String)


70
71
72
# File 'lib/vedeu/templating/decoder.rb', line 70

def unwrap
  data.gsub(/({{)|(}})/, '')
end