Class: Coradoc::Element::Table
- Inherits:
-
Object
- Object
- Coradoc::Element::Table
- Defined in:
- lib/coradoc/element/table.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(title, rows, options = {}) ⇒ Table
constructor
A new instance of Table.
- #to_adoc ⇒ Object
Constructor Details
#initialize(title, rows, options = {}) ⇒ Table
Returns a new instance of Table.
6 7 8 9 10 11 12 |
# File 'lib/coradoc/element/table.rb', line 6 def initialize(title, rows, = {}) @rows = rows @title = title @id = .fetch(:id, nil) @anchor = @id.nil? ? nil : Inline::Anchor.new(@id) @attrs = .fetch(:attrs, '') end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
4 5 6 |
# File 'lib/coradoc/element/table.rb', line 4 def content @content end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/coradoc/element/table.rb', line 4 def id @id end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
4 5 6 |
# File 'lib/coradoc/element/table.rb', line 4 def rows @rows end |
#title ⇒ Object (readonly)
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
15 16 17 18 19 20 21 22 |
# File 'lib/coradoc/element/table.rb', line 15 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 |