Class: Vedeu::Templating::Encoder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/templating/encoder.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 object or collection of objects into an encoded String.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

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::Encoder.

Parameters:

  • data (Object)


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

def initialize(data)
  @data = data
end

Instance Attribute Details

#dataObject (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:

  • (Object)


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

def data
  @data
end

Class Method Details

.process(data) ⇒ String

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 (Object)

Returns:

  • (String)


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

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

Instance Method Details

#compressString (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.

Compress the marshalled object or objects.

Returns:

  • (String)


62
63
64
# File 'lib/vedeu/templating/encoder.rb', line 62

def compress
  Zlib::Deflate.deflate(marshal)
end

#encode64String (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.

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

Returns:

  • (String)


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

def encode64
  Base64.strict_encode64(compress)
end

#marshalString (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 object or objects into marshalled object(s).

Returns:

  • (String)


69
70
71
# File 'lib/vedeu/templating/encoder.rb', line 69

def marshal
  Marshal.dump(data)
end

#processString

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 object or collection of objects into an encoded String.

Returns:

  • (String)


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

def process
  wrap
end

#wrapString (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.

Adds delimiters to the start and end of the data.

Returns:

  • (String)


47
48
49
# File 'lib/vedeu/templating/encoder.rb', line 47

def wrap
  "{{#{encode64}}}"
end