Class: Coradoc::Element::Table
- Defined in:
- lib/coradoc/element/table.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#id ⇒ Object
Returns the value of attribute id.
-
#rows ⇒ Object
Returns the value of attribute rows.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(title, rows, options = {}) ⇒ Table
constructor
A new instance of Table.
- #to_adoc ⇒ Object
Methods inherited from Base
#children_accessors, children_accessors, declare_children, #simplify_block_content, visit, #visit
Constructor Details
#initialize(title, rows, options = {}) ⇒ Table
Returns a new instance of Table.
8 9 10 11 12 13 14 |
# File 'lib/coradoc/element/table.rb', line 8 def initialize(title, rows, = {}) @rows = rows @title = title @id = .fetch(:id, nil) @anchor = @id.nil? ? nil : Inline::Anchor.new(@id) @attrs = .fetch(:attributes, nil) end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
4 5 6 |
# File 'lib/coradoc/element/table.rb', line 4 def content @content end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/coradoc/element/table.rb', line 4 def id @id end |
#rows ⇒ Object
Returns the value of attribute rows.
4 5 6 |
# File 'lib/coradoc/element/table.rb', line 4 def rows @rows end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/coradoc/element/table.rb', line 4 def title @title end |
Instance Method Details
#to_adoc ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/coradoc/element/table.rb', line 16 def to_adoc anchor = @anchor.nil? ? "" : "#{@anchor.to_adoc}\n" attrs = @attrs.to_s.empty? ? "" : "#{@attrs.to_adoc}\n" title = Coradoc::Generator.gen_adoc(@title) title = title.empty? ? "" : ".#{title}\n" content = @rows.map(&:to_adoc).join "\n\n#{anchor}#{attrs}#{title}|===\n" << content << "\n|===\n" end |