Class: GfmToBlockkit::Converters::Table::Native
- Defined in:
- lib/gfm_to_blockkit/converters/table/native.rb
Instance Method Summary collapse
Methods inherited from Base
converter_for, handles, #initialize, #render_child_as_elements
Constructor Details
This class inherits a constructor from GfmToBlockkit::Converters::Base
Instance Method Details
#convert(node) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gfm_to_blockkit/converters/table/native.rb', line 7 def convert(node) rows = extract_rows(node) return [] if rows.empty? header = rows.first body = rows[1..] || [] columns = header.map do |cell| {type: "text", text: {type: "plain_text", text: cell}} end table_rows = body.map do |row| { type: "table_row", cells: row.map { |cell| {type: "plain_text", text: cell} } } end [{ type: "table", columns: columns, rows: table_rows }] end |