Class: MarkdownTable::Table
- Inherits:
-
Object
- Object
- MarkdownTable::Table
- Defined in:
- lib/markdown_table/table.rb
Instance Method Summary collapse
- #<<(fields) ⇒ Object
- #generate ⇒ Object
-
#initialize(header:, align:) ⇒ Table
constructor
A new instance of Table.
Constructor Details
#initialize(header:, align:) ⇒ Table
Returns a new instance of Table.
9 10 11 12 13 |
# File 'lib/markdown_table/table.rb', line 9 def initialize(header:, align:) @header = MarkdownTable::Header.new(header:) @align_row = MarkdownTable::AlignRow.new(size: header.size, align: align.map(&:to_sym)) @rows = [] end |
Instance Method Details
#<<(fields) ⇒ Object
23 24 25 |
# File 'lib/markdown_table/table.rb', line 23 def <<(fields) @rows << MarkdownTable::Row.new(fields:) end |
#generate ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/markdown_table/table.rb', line 15 def generate table = @header.generate table += @align_row.generate table += @rows.inject('') { |result, row| result + row.generate } table end |