Class: Vedeu::Output::Compressor Private

Inherits:
Object
  • Object
show all
Includes:
Common, Renderers::Options
Defined in:
lib/vedeu/output/compressor.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.

During the conversion of a Vedeu::Cells::Char object into a string of escape sequences, this class removes multiple occurences of the same escape sequence, resulting in a smaller payload being sent to the renderer.

Instance Attribute Summary collapse

Attributes included from Renderers::Options

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Renderers::Options

#clear, #compression, #compression?, #default_template, #defaults, #end_row_tag, #end_tag, #filename, #start_row_tag, #start_tag, #template, #timestamp, #timestamp?, #write, #write_file, #write_file?

Methods included from Common

#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?

Constructor Details

#initialize(output, options = {}) ⇒ Vedeu::Output::Compressor

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::Output::Compressor.

Parameters:

Options Hash (options):



31
32
33
34
# File 'lib/vedeu/output/compressor.rb', line 31

def initialize(output, options = {})
  @output  = output
  @options = options
end

Instance Attribute Details

#outputArray<Array<Vedeu::Cells::Char>> (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:



51
52
53
# File 'lib/vedeu/output/compressor.rb', line 51

def output
  @output
end

Class Method Details

.render(output, options = {}) ⇒ String, Array<void>|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:

Returns:

  • (String)
  • (Array<void>|String)


21
22
23
# File 'lib/vedeu/output/compressor.rb', line 21

def self.render(output, options = {})
  new(output, options).render
end

Instance Method Details

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

Returns the output with all of the empty cells removed to make compression faster.

Returns:

  • (Array)


59
60
61
# File 'lib/vedeu/output/compressor.rb', line 59

def content
  Vedeu::Output::Compressors::Empty.with(output.content)
end

#output?Boolean (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.

Returns:



64
65
66
# File 'lib/vedeu/output/compressor.rb', line 64

def output?
  present?(output)
end

#renderString, Array<void>|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.

Note:
  • Takes approximately ~6ms for 2100 chars. (2015-11-25)

  • Takes approximately ~25ms for 2100 chars. (2015-07-25)

Returns:

  • (String)
  • (Array<void>|String)


41
42
43
44
45
# File 'lib/vedeu/output/compressor.rb', line 41

def render
  return [] unless output?

  Vedeu::Output::CompressorCache.cache(content, compression?)
end