Class: Docgenerator::Tables::Tabular
- Defined in:
- lib/docgenerator/tabular.rb
Overview
Tabulars
fixme: check on attributes. columnsdescription ~ :table=> :width=>nil, :cellpadding=>nil, :cellspacing=>nil,#complete it ~ :colgroup => {}, #complete it
Constant Summary
Constants inherited from Element
Constants included from Docgenerator
ATTR_LANG, CSS_BORDER, CSS_COLORS, CSS_WIDTH, DOCGENERATOR_DEFAULT_LOGGER, DOCGENERATOR_LOGGER, ENDTAG, HTML_ATTR_ALIGN, HTML_ATTR_ALL, HTML_ATTR_CORE, HTML_ATTR_EVENTS, HTML_ATTR_I18N, HTML_ATTR_VALIGN, VERSION
Instance Attribute Summary
Attributes inherited from Element
Instance Method Summary collapse
-
#<<(row) ⇒ Object
-
Only rows are allowed to be added.
-
- #htmltag ⇒ Object
- #inspect ⇒ Object
-
#to_creole(options = {}) ⇒ Object
Output a complete tabular in wikimedia-like tabular extension for creole.
- #to_latex(options = {}) ⇒ Object
- #to_text(options = {}) ⇒ Object
- #to_wiki(options = {}) ⇒ Object
Methods inherited from Element
#CR, #Cr, #[], add, add_attribute, add_attributes, add_context_output, add_creole_output, add_html_output, add_html_tag, add_id, add_latex_output, add_output, add_text_output, add_wiki_output, attributes, #cR, #content?, #cr, create, create_convert_to_code, #delete, #element_ids, element_ids, #empty?, get, get_attribute_list, has_no_content, #ids, inherited, #initialize, #insert, #insertafter, #insertbefore, #inspect_creation_caller, #linebreak, overview, #prepare_tracing_info, #restrict_to, #texkeyval, #texoptional, #to_context, #to_doc, #to_html, #to_s, trace=
Methods included from Docgenerator
#set_option_defaults, set_option_defaults, trace_off, trace_on, trace_on?
Constructor Details
This class inherits a constructor from Docgenerator::Element
Instance Method Details
#<<(row) ⇒ Object
-
Only rows are allowed to be added.
-
The row gets the number of columns (attr)
-
The row counting does not work, when the row-content is added immediate during element-initialization.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/docgenerator/tabular.rb', line 56 def << ( row ) #Check on allowed elements for a tabular allowed = false [ :row, :hline, :toprule, :midrule, :bottomrule, :endfirsthead , :endhead , :endfoot, :endlastfoot, :caption ].each{|el| if row.is_a?( Element.get(el) ) allowed = true break end } if ! allowed @log.warn("Add non-row to tabular (#{row.class})") if @log.warn? end #Add number of expected columns if row.is_a?( Row ) row.columns = @attr[:columns].to_s.to_i end @content << row end |
#htmltag ⇒ Object
107 108 109 |
# File 'lib/docgenerator/tabular.rb', line 107 def htmltag() return 'table' end |
#inspect ⇒ Object
110 111 112 |
# File 'lib/docgenerator/tabular.rb', line 110 def inspect() return "<Class Element(tabular) columns=#{@attr[:columns]}>" end |
#to_creole(options = {}) ⇒ Object
Output a complete tabular in wikimedia-like tabular extension for creole.
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/docgenerator/tabular.rb', line 94 def to_creole(={}); creole = '' creole << "<<<tabular\n" creole << "|!columns=#{@attr[:columns].content.first}\n" if @attr[:columns].filled? creole << "|!columndescription=%s\n" % @attr[:columndescription].content if @attr[:columndescription].filled? #Add css-components @attr[:style].content.first.to_tab.each{|css| #loop on Docgenerator::CSS creole << "|!css=%s\n" % css } if @attr[:style].filled? creole << "#{@content.to_creole().strip}\n" creole << ">>>\n" return creole end |
#to_latex(options = {}) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/docgenerator/tabular.rb', line 75 def to_latex(={}) o = set_option_defaults() o[:log].debug("enter to_latex for tabular") if o[:log].debug? cmd = '' cmd << "\n" if @crbefore cmd << "\\begin{tabular}{" cmd << @attr[:columndescription].content.to_doc(:latex, o) cmd << "}" cmd << "\n" if @crmid cmd << @content.to_doc(:latex, o ) cmd << "\\end{tabular}" cmd << "\n" if @crafter return cmd end |
#to_text(options = {}) ⇒ Object
89 |
# File 'lib/docgenerator/tabular.rb', line 89 def to_text(={}); return @content.to_text(); end |
#to_wiki(options = {}) ⇒ Object
90 |
# File 'lib/docgenerator/tabular.rb', line 90 def to_wiki(={}); return "{|\n#{@content.to_wiki().strip}\n|}\n"; end |