Class: Vedeu::Renderers::Escape Private

Inherits:
File
  • Object
show all
Includes:
Options
Defined in:
lib/vedeu/renderers/escape.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 a grid of Cells objects or Cells::Char objects into a stream of characters without escape sequences.

Instance Attribute Summary

Attributes included from Options

#options

Instance Method Summary collapse

Methods included from Options

#compression, #compression?, #default_template, #defaults, #end_row_tag, #end_tag, #filename, #initialize, #output, #output?, #render, #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?

Methods inherited from File

#write, #write_file?

Instance Method Details

#bufferArray<String> (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:

  • (Array<String>)


39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/vedeu/renderers/escape.rb', line 39

def buffer
  empty = Array.new(Vedeu.height) { Array.new(Vedeu.width) { '[:cell]' } }

  output.each do |row|
    row.each do |char|
      next unless positionable?(char)

      empty[char.position.y - 1][char.position.x - 1] = char.to_ast
    end
  end

  empty
end

#clearString

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.

Render a cleared output.

Returns:

  • (String)


20
21
22
# File 'lib/vedeu/renderers/escape.rb', line 20

def clear
  render('[[:clear]]')
end

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

Combine all characters in a row to produce a line, then all lines should be terminated with ‘n`. Convert to an array of UTF8 codepoints, and any codepoint above 255 should be converted to a space.

Returns:

  • (String)


32
33
34
35
36
# File 'lib/vedeu/renderers/escape.rb', line 32

def content
  return '[[:empty]]' if string?(output) || absent?(output)

  buffer.map { |row| row.join("\n") }.join("\n\n")
end