tj / terminal-table

Ruby ASCII Table Generator, simple and feature rich.
MIT License
1.53k stars 121 forks source link

Allows setting headings to nil #133

Open dorianmariecom opened 1 month ago

dorianmariecom commented 1 month ago

Just skips the whole initialization of headings

here is what i was doing:

    def table(data)
      is_hashes = data.first.from_deep_struct.is_a?(Hash)
      headings = is_hashes ? data.first.to_h.keys : nil
      rows = is_hashes ? data.map(&:values) : data.map { |row| wrap(row) }
      puts Terminal::Table.new(headings: headings, rows: rows)
    end