Module: Vedeu::Renderers::Options
- Includes:
- Common
- Defined in:
- lib/vedeu/renderers/support/options.rb
Overview
Provides shared functionality to Vedeu::Renderer classes.
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#clear ⇒ String
Render a cleared output.
-
#compression ⇒ String
private
Compresses the output depending on configuration.
-
#compression? ⇒ Boolean
private
Returns a boolean indicating whether the content should be compressed if compression is available.
- #content ⇒ Object private
- #default_template ⇒ String private
-
#defaults ⇒ Hash<Symbol => void>
private
The default options/attributes for a new instance of this class.
- #end_row_tag ⇒ String private
- #end_tag ⇒ String private
-
#filename ⇒ String
private
Return the filename given in the options, (or use the default), and append a timestamp if the :timestamp option was set to true.
-
#initialize(opts = {}) ⇒ void
Returns a new instance of the class including this module.
- #output ⇒ Array<void> private
- #output? ⇒ Boolean private
- #render(output = '') ⇒ void
- #start_row_tag ⇒ String private
- #start_tag ⇒ String private
- #template ⇒ String private
-
#timestamp ⇒ String
private
Return a timestamp for use as part of the filename if the :timestamp option was set to true, otherwise an empty string.
- #timestamp? ⇒ Boolean private
- #write ⇒ Object
-
#write_file ⇒ String
private
Render the output (either content or clearing) to a file.
-
#write_file? ⇒ Boolean
private
Returns a boolean indicating whether a file should be written.
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?
Instance Attribute Details
#options ⇒ Hash<Symbol => void>
15 16 17 |
# File 'lib/vedeu/renderers/support/options.rb', line 15 def @options end |
Instance Method Details
#clear ⇒ String
Render a cleared output.
42 43 44 |
# File 'lib/vedeu/renderers/support/options.rb', line 42 def clear render('') end |
#compression ⇒ String (private)
Compresses the output depending on configuration.
72 73 74 75 76 77 78 79 80 |
# File 'lib/vedeu/renderers/support/options.rb', line 72 def compression if compression? Vedeu::Output::Compressor.render(output, ) else output end end |
#compression? ⇒ Boolean (private)
Returns a boolean indicating whether the content should be compressed if compression is available.
65 66 67 |
# File 'lib/vedeu/renderers/support/options.rb', line 65 def compression? boolean([:compression]) end |
#content ⇒ Object (private)
83 84 85 |
# File 'lib/vedeu/renderers/support/options.rb', line 83 def content raise Vedeu::Error::NotImplemented end |
#default_template ⇒ String (private)
104 105 106 |
# File 'lib/vedeu/renderers/support/options.rb', line 104 def default_template ::File.dirname(__FILE__) + '/../templates/html_renderer.vedeu' end |
#defaults ⇒ Hash<Symbol => void> (private)
The default options/attributes for a new instance of this class.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/vedeu/renderers/support/options.rb', line 88 def defaults { compression: Vedeu.config.compression?, end_tag: '</td>', end_row_tag: '</tr>', filename: Dir.tmpdir + '/vedeu_out', output: '', start_tag: '<td', start_row_tag: '<tr>', template: default_template, timestamp: false, write_file: false, } end |
#end_row_tag ⇒ String (private)
114 115 116 |
# File 'lib/vedeu/renderers/support/options.rb', line 114 def end_row_tag [:end_row_tag] end |
#end_tag ⇒ String (private)
109 110 111 |
# File 'lib/vedeu/renderers/support/options.rb', line 109 def end_tag [:end_tag] end |
#filename ⇒ String (private)
Return the filename given in the options, (or use the default), and append a timestamp if the :timestamp option was set to true.
123 124 125 |
# File 'lib/vedeu/renderers/support/options.rb', line 123 def filename [:filename] + end |
#initialize(opts = {}) ⇒ void
Returns a new instance of the class including this module.