Class: Vedeu::Renderers::HTML

Inherits:
File
  • Object
show all
Includes:
Options
Defined in:
lib/vedeu/renderers/html.rb

Overview

Renders a Buffers::Terminal as a HTML snippet; a table by default.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsHash<Symbol => void> Originally defined in module Options

Returns:

  • (Hash<Symbol => void>)

Instance Method Details

#absent?(variable) ⇒ Boolean Originally defined in module Common

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 boolean indicating whether a variable is nil or empty.

Parameters:

  • variable (String|Symbol|Array|Fixnum)

    The variable to check.

Returns:

#become(klass, attributes) ⇒ Class Originally defined in module Common

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 one class into another.

Parameters:

  • klass (Class)

    The class to become an instance of.

  • attributes (Hash)

    The attributes of klass.

Returns:

  • (Class)

    Returns a new instance of klass.

#boolean(value) ⇒ Boolean Originally defined in module Common

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 boolean indicating the value was a boolean.

Parameters:

  • value (void)

Returns:

#boolean?(value) ⇒ Boolean Originally defined in module Common

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 boolean indicating whether the value is a Boolean.

Parameters:

Returns:

#clearvoid Originally defined in module Options

This method returns an undefined value.

#compressionString (private) Originally defined in module Options

Compresses the output depending on configuration.

Returns:

  • (String)

#compression?Boolean (private) Originally defined in module Options

Returns a boolean indicating whether the content should be compressed if compression is available.

Returns:

#contentString (private)

Returns:

  • (String)


34
35
36
37
38
39
40
41
42
# File 'lib/vedeu/renderers/html.rb', line 34

def content
  if valid?
    Vedeu::Templating::Template.parse(self, template)

  else
    ''

  end
end

#default_templateString (private) Originally defined in module Options

Returns:

  • (String)

#defaultsHash<Symbol => void> (private) Originally defined in module Options

The default values for a new instance of this class.

Returns:

  • (Hash<Symbol => void>)

#end_row_tagString (private) Originally defined in module Options

Returns:

  • (String)

#end_tagString (private) Originally defined in module Options

Returns:

  • (String)

#escape?(value) ⇒ Boolean Originally defined in module Common

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 boolean indicating whether the value is an escape sequence object (e.g. Vedeu::Cells::Escape.)

Returns:

#falsy?(value) ⇒ Boolean Originally defined in module Common

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 boolean indicating whether the value should be considered false.

Parameters:

  • value (void)

Returns:

#filenameString (private) Originally defined in module Options

Return the filename given in the options, (or use the default), and append a timestamp if the :timestamp option was set to true.

Returns:

  • (String)

#hash?(value) ⇒ Boolean Originally defined in module Common

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 boolean indicating whether the value is a Hash.

Parameters:

  • value (Hash|void)

Returns:

#html_bodyString

Returns:

  • (String)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/vedeu/renderers/html.rb', line 15

def html_body
  if valid?
    output.inject([]) do |acc, line|
      acc << "#{start_row_tag}\n"
      line.each do |char|
        acc << char.to_html(options)
      end
      acc << "#{end_row_tag}\n"
    end.join

  else
    ''

  end
end

#initialize(opts = {}) ⇒ void Originally defined in module Options

Returns a new instance of the class including this module.

Parameters:

  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • content (String)

    Defaults to an empty string.

  • end_tag (String)

    Defaults to ‘</td>’.

  • end_row_tag (String)

    Defaults to ‘</tr>’.

  • filename (String)

    Provide a filename for the output. Defaults to ‘out’.

  • start_tag (String)

    Defaults to ‘<td’ (note the end of the tag is missing, this is so that inline styles can be added later).

  • start_row_tag (String)

    Defaults to ‘<tr>’.

  • template (String)
  • timestamp (Boolean)

    Append a timestamp to the filename.

  • write_file (Boolean)

    Whether to write the file to the given filename.

#line_model?Boolean Originally defined in module Common

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 boolean indicating the model is a Views::Line.

Returns:

#numeric?(value) ⇒ Boolean Originally defined in module Common

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 boolean indicating whether the value is a Fixnum.

Parameters:

  • value (Fixnum|void)

Returns:

#outputvoid (private) Originally defined in module Options

This method returns an undefined value.

#output?Boolean (private) Originally defined in module Options

Returns:

#present?(variable) ⇒ Boolean Originally defined in module Common

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 boolean indicating whether a variable has a useful value.

Parameters:

  • variable (String|Symbol|Array|Fixnum)

    The variable to check.

Returns:

#render(output = '') ⇒ void Originally defined in module Options

This method returns an undefined value.

Parameters:

#snake_case(klass) ⇒ String Originally defined in module Common

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 a class name to a lowercase snake case string.

Examples:

snake_case(MyClassName) # => "my_class_name"
snake_case(NameSpaced::ClassName)
# => "name_spaced/class_name"

snake_case('MyClassName') # => "my_class_name"
snake_case(NameSpaced::ClassName)
# => "name_spaced/class_name"

Parameters:

  • klass (Module|Class|String)

Returns:

  • (String)

#start_row_tagString (private) Originally defined in module Options

Returns:

  • (String)

#start_tagString (private) Originally defined in module Options

Returns:

  • (String)

#stream_model?Boolean Originally defined in module Common

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 boolean indicating the model is a Views::Stream.

Returns:

#string?(value) ⇒ Boolean Originally defined in module Common

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 boolean indicating whether the value is a Fixnum.

Parameters:

  • value (String|void)

Returns:

#templateString (private) Originally defined in module Options

Returns:

  • (String)

#timestampString (private) Originally defined in module Options

Return a timestamp for use as part of the filename if the :timestamp option was set to true, otherwise an empty string.

Returns:

  • (String)

#timestamp?Boolean (private) Originally defined in module Options

Returns:

#truthy?(value) ⇒ Boolean Originally defined in module Common

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 boolean indicating whether the value should be considered true.

Parameters:

  • value (void)

Returns:

#valid?Boolean (private)

Returns:



45
46
47
48
49
# File 'lib/vedeu/renderers/html.rb', line 45

def valid?
  return false if string?(output) || escape?(output)

  true
end

#view_model?Boolean Originally defined in module Common

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 boolean indicating the model is a Views::View.

Returns:

#writeObject Originally defined in module Options

Raises:

  • (Vedeu::Error::NotImplemented)

    When a subclass of the current class actually implements the method. Usually an indicator that the subclass should be used instead of the current class.

#write_fileString (private) Originally defined in module Options

Render the output (either content or clearing) to a file.

Returns:

  • (String)

#write_file?Boolean (private) Originally defined in module Options

Returns a boolean indicating whether a file should be written.

Returns: