Module: Vedeu::Renderers::Options
- Includes:
- Common
- Defined in:
- lib/vedeu/renderers/options.rb
Overview
Provides shared functionality to Vedeu::Renderer classes.
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#absent?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable is nil or empty.
-
#become(klass, attributes) ⇒ Class
included
from Common
private
Converts one class into another.
-
#boolean(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating the value was a boolean.
-
#boolean?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Boolean.
- #clear ⇒ void
-
#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 values for a new instance of this class.
- #end_row_tag ⇒ String private
- #end_tag ⇒ String private
-
#escape?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is an escape sequence object (e.g. Cells::Escape.).
-
#falsy?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value should be considered false.
-
#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.
-
#hash?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Hash.
-
#initialize(opts = {}) ⇒ void
Returns a new instance of the class including this module.
-
#line_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::Line.
-
#numeric?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Fixnum.
- #output ⇒ void private
- #output? ⇒ Boolean private
-
#present?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable has a useful value.
- #render(output = '') ⇒ void
-
#snake_case(klass) ⇒ String
included
from Common
private
Converts a class name to a lowercase snake case string.
- #start_row_tag ⇒ String private
- #start_tag ⇒ String private
-
#stream_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::Stream.
-
#string?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Fixnum.
- #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
-
#truthy?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value should be considered true.
-
#view_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::View.
- #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.
Instance Attribute Details
#options ⇒ Hash<Symbol => void>
15 16 17 |
# File 'lib/vedeu/renderers/options.rb', line 15 def end |
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.
#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.
#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.
#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.
#clear ⇒ void
This method returns an undefined value.
40 41 42 |
# File 'lib/vedeu/renderers/options.rb', line 40 def clear render('') end |
#compression ⇒ String (private)
Compresses the output depending on configuration.
70 71 72 73 74 75 76 77 78 |
# File 'lib/vedeu/renderers/options.rb', line 70 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.
63 64 65 |
# File 'lib/vedeu/renderers/options.rb', line 63 def compression? boolean([:compression]) end |
#content ⇒ Object (private)
81 82 83 |
# File 'lib/vedeu/renderers/options.rb', line 81 def content fail Vedeu::Error::NotImplemented, 'Including classes implement this.' end |
#default_template ⇒ String (private)
104 105 106 |
# File 'lib/vedeu/renderers/options.rb', line 104 def default_template ::File.dirname(__FILE__) + '/./templates/html_renderer.vedeu' end |
#defaults ⇒ Hash<Symbol => void> (private)
The default values 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/options.rb', line 88 def defaults { compression: Vedeu.config.compression?, end_tag: '</td>', end_row_tag: '</tr>', filename: '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/options.rb', line 114 def end_row_tag [:end_row_tag] end |
#end_tag ⇒ String (private)
109 110 111 |
# File 'lib/vedeu/renderers/options.rb', line 109 def end_tag [:end_tag] end |
#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.)
#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.
#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/options.rb', line 123 def filename [:filename] + end |
#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.
#initialize(opts = {}) ⇒ void
Returns a new instance of the class including this module.
35 36 37 |
# File 'lib/vedeu/renderers/options.rb', line 35 def initialize(opts = {}) = defaults.merge!(opts || {}) end |
#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.
#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.
#output ⇒ void (private)
This method returns an undefined value.
138 139 140 |
# File 'lib/vedeu/renderers/options.rb', line 138 def output [:output] end |
#output? ⇒ Boolean (private)
143 144 145 |
# File 'lib/vedeu/renderers/options.rb', line 143 def output? present?(output) end |
#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.
#render(output = '') ⇒ void
This method returns an undefined value.
46 47 48 49 50 |
# File 'lib/vedeu/renderers/options.rb', line 46 def render(output = '') [:output] = output write end |
#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.
#start_row_tag ⇒ String (private)
133 134 135 |
# File 'lib/vedeu/renderers/options.rb', line 133 def start_row_tag [:start_row_tag] end |
#start_tag ⇒ String (private)
128 129 130 |
# File 'lib/vedeu/renderers/options.rb', line 128 def start_tag [:start_tag] end |
#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.
#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.
#template ⇒ String (private)
148 149 150 |
# File 'lib/vedeu/renderers/options.rb', line 148 def template [:template] end |
#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.
161 162 163 164 165 |
# File 'lib/vedeu/renderers/options.rb', line 161 def return "_#{Vedeu.clock_time}" if '' end |
#timestamp? ⇒ Boolean (private)
153 154 155 |
# File 'lib/vedeu/renderers/options.rb', line 153 def boolean([:timestamp]) end |
#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.
#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.
#write ⇒ Object
53 54 55 |
# File 'lib/vedeu/renderers/options.rb', line 53 def write fail Vedeu::Error::NotImplemented, 'Including classes implement this.' end |
#write_file ⇒ String (private)
Render the output (either content or clearing) to a file.
177 178 179 180 181 182 183 |
# File 'lib/vedeu/renderers/options.rb', line 177 def write_file data = content ::File.write(filename, data) data end |
#write_file? ⇒ Boolean (private)
Returns a boolean indicating whether a file should be written.
170 171 172 |
# File 'lib/vedeu/renderers/options.rb', line 170 def write_file? boolean([:write_file]) end |