Class: Vedeu::Renderers::File

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

Overview

Writes the given output to a file.

Direct Known Subclasses

Escape, HTML, JSON, Text

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:

#clearString

Returns:

  • (String)


14
15
16
# File 'lib/vedeu/renderers/file.rb', line 14

def clear
  render('')
end

#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)


32
33
34
# File 'lib/vedeu/renderers/file.rb', line 32

def content
  output
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:

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

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

#writeString

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

Returns:

  • (String)


21
22
23
24
25
26
27
# File 'lib/vedeu/renderers/file.rb', line 21

def write
  data = content

  ::File.write(filename, data)

  data
end

#write_fileString (private) Originally defined in module Options

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

Returns:

  • (String)

#write_file?Boolean (private)

Returns:



37
38
39
# File 'lib/vedeu/renderers/file.rb', line 37

def write_file?
  true
end