Class: Docgenerator::Tables::Column
- Defined in:
- lib/docgenerator/tabular.rb
Overview
A column/cell in a tabular.
Direct Known Subclasses
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
- #content? ⇒ Boolean
- #htmltag ⇒ Object
- #inspect ⇒ Object
-
#to_creole(options = {}) ⇒ Object
Create a tabular-cell in 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, #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
#content? ⇒ Boolean
533 |
# File 'lib/docgenerator/tabular.rb', line 533 def content?; :empty_ok; end |
#htmltag ⇒ Object
534 535 536 |
# File 'lib/docgenerator/tabular.rb', line 534 def htmltag() return 'td' end |
#inspect ⇒ Object
574 575 576 |
# File 'lib/docgenerator/tabular.rb', line 574 def inspect() return "<Class Column @content=#{@content.inspect}>" end |
#to_creole(options = {}) ⇒ Object
Create a tabular-cell in creole.
This implements the docgenerator specific tabular version similar to wikimedia-syntax.
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 |
# File 'lib/docgenerator/tabular.rb', line 544 def to_creole(={}) o = set_option_defaults() o[:log].debug("enter to_creole for column") if o[:log].debug? result = "|" result << "#{@content.to_creole().strip}" if result.gsub!("\n", ' ') o[:log].warn("Tabular cell contained newline") if o[:log].warn? end result << "||" #separator between content and options #Attach options @attr.each{|attr_key, attr| next unless attr.filled? #ignore empty attributes case attr_key when :style result << "css=#{attr.content.join}|" when :class result << "class=#{attr.content.join}|" when :title result << "title=#{attr.content.join}|" when :columns ##from multicolumns else #~ p attr_key o[:log].debug("unsupported attribute #{attr_key} in to_creole for column") if o[:log].debug? end } result << "\n" result.sub!(/\|\|\n/, "\n") #remove options separator, if no options available return result end |
#to_latex(options = {}) ⇒ Object
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 |
# File 'lib/docgenerator/tabular.rb', line 518 def to_latex(={}) o = set_option_defaults() o[:log].debug("enter to_latex for column") if o[:log].debug? cmd = '' cmd << "\n" if @crbefore cmd << if self.is_a?(Column_th ) element(:textbf,{}, @content).to_latex(o) #make bold for header line else "#{@content.to_latex(o)}" end cmd << "\n" if @crafter #The sub.command is needed to avoid problems like [xx] after a \\ #Details see https://de.wikibooks.org/wiki/LaTeX-W%C3%B6rterbuch:_TeX_Primitiven:_%5Crelax return cmd.sub(/\A\[/, '\relax [') end |
#to_text(options = {}) ⇒ Object
537 |
# File 'lib/docgenerator/tabular.rb', line 537 def to_text(={}); return "#{@content.to_text().strip}\n"; end |
#to_wiki(options = {}) ⇒ Object
538 |
# File 'lib/docgenerator/tabular.rb', line 538 def to_wiki(={}); return "|#{@content.to_wiki().strip}\n"; end |