Method: Faker::Markdown.table

Defined in:
lib/faker/default/markdown.rb

.tableString

Produces a random 3x4 table with a row of headings, a row of hyphens and two rows of data

Examples:

Faker::Markdown.table #=> "ad | similique | voluptatem\n---- | ---- | ----\ncorrupti | est | rerum\nmolestiae | quidem | et"

Returns:

  • (String)

Available since:

  • 1.8.0



110
111
112
113
114
115
116
117
# File 'lib/faker/default/markdown.rb', line 110

def table
  table = []
  3.times do
    table << "#{Lorem.word} | #{Lorem.word} | #{Lorem.word}"
  end
  table.insert(1, '---- | ---- | ----')
  table.join("\n")
end