Class: Docgenerator::CSS_collection
- Defined in:
- lib/docgenerator/templates/docgenerator_template_css.rb
Overview
Definition of templates.
This templates are used for document types.
Constant Summary collapse
- @@templates =
{}
Class Method Summary collapse
-
.[](key) ⇒ Object
Get CSS_Collection.
-
.keys ⇒ Object
Returns array with all defined template keys.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Get CSS-style for new definition.
-
#add(key, css) ⇒ Object
Add a css definition to the collection.
-
#css ⇒ Object
Returns the complete CSS-definition.
-
#initialize(key, descr) ⇒ CSS_collection
constructor
Define a CSS template.
-
#style ⇒ Object
Returns the Style definition for the HTTP-Head.
Constructor Details
#initialize(key, descr) ⇒ CSS_collection
Define a CSS template.
If key is nil (or false), an anonym CSS-Collection is made
14 15 16 17 18 19 20 21 22 |
# File 'lib/docgenerator/templates/docgenerator_template_css.rb', line 14 def initialize( key, descr ) @key = key @descr = descr @css = {} if @@templates[key] DOCGENERATOR_LOGGER.warn("DocumentTemplateCSS: Double definition of template #{key.inspect}") if DOCGENERATOR_LOGGER.warn? end @@templates[key] = self if @key end |
Class Method Details
.[](key) ⇒ Object
Get CSS_Collection.
54 55 56 57 58 59 60 |
# File 'lib/docgenerator/templates/docgenerator_template_css.rb', line 54 def self.[]( key ) if @@templates[key] return @@templates[key] else return nil end end |
.keys ⇒ Object
Returns array with all defined template keys.
62 63 64 |
# File 'lib/docgenerator/templates/docgenerator_template_css.rb', line 62 def self.keys() return @@templates.keys end |
Instance Method Details
#[](key) ⇒ Object
Get CSS-style for new definition.
29 30 31 |
# File 'lib/docgenerator/templates/docgenerator_template_css.rb', line 29 def []( key ) @css[key] end |
#add(key, css) ⇒ Object
Add a css definition to the collection. key is the CSS-locator, e.g. “div.toc ul li a”
25 26 27 |
# File 'lib/docgenerator/templates/docgenerator_template_css.rb', line 25 def add( key, css) @css[key] = css end |
#css ⇒ Object
Returns the complete CSS-definition.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/docgenerator/templates/docgenerator_template_css.rb', line 33 def css() css_coll = "/*\n" css_coll << "\t#{@descr}" css_coll << "\n*/\n" @css.each{|k,css| css_coll << "#{k}\t{\n" css_coll << css.to_html(:map => "\t%s;\n") css_coll << "}\n" } css_coll end |
#style ⇒ Object
Returns the Style definition for the HTTP-Head.
Use it like this:
doc.head << CSS_collection[:toc].style
50 51 52 |
# File 'lib/docgenerator/templates/docgenerator_template_css.rb', line 50 def style() return element(:style, {}, self.css ) end |