class Faker::Markdown

Public Class Methods

block_code() click to toggle source
# File lib/faker/default/markdown.rb, line 43
def block_code
  "```ruby\n#{Lorem.sentence(word_count: 1)}\n```"
end
emphasis() click to toggle source
# File lib/faker/default/markdown.rb, line 10
def emphasis
  paragraph = Faker::Lorem.paragraph(sentence_count: 3)
  words = paragraph.split(' ')
  position = rand(0..words.length - 1)
  formatting = fetch('markdown.emphasis')
  words[position] = "#{formatting}#{words[position]}#{formatting}"
  words.join(' ')
end
headers() click to toggle source
# File lib/faker/default/markdown.rb, line 6
def headers
  "#{fetch('markdown.headers')} #{Lorem.word.capitalize}"
end
inline_code() click to toggle source
# File lib/faker/default/markdown.rb, line 39
def inline_code
  "`#{Faker::Lorem.sentence(word_count: 1)}`"
end
ordered_list() click to toggle source
# File lib/faker/default/markdown.rb, line 19
def ordered_list
  number = rand(1..10)

  result = []
  number.times do |i|
    result << "#{i}. #{Faker::Lorem.sentence(word_count: 1)} \n"
  end
  result.join('')
end
random(*args) click to toggle source
# File lib/faker/default/markdown.rb, line 56
def random(*args)
  method_list = available_methods
  args&.each { |ex| method_list.delete_if { |meth| meth == ex.to_sym } }
  send(method_list[rand(0..method_list.length - 1)])
end
sandwich(legacy_sentences = NOT_GIVEN, legacy_repeat = NOT_GIVEN, sentences: 3, repeat: 1) click to toggle source
# File lib/faker/default/markdown.rb, line 62
def sandwich(legacy_sentences = NOT_GIVEN, legacy_repeat = NOT_GIVEN, sentences: 3, repeat: 1)
  warn_for_deprecated_arguments do |keywords|
    keywords << :sentences if legacy_sentences != NOT_GIVEN
    keywords << :repeat if legacy_repeat != NOT_GIVEN
  end

  text_block = []
  text_block << headers
  repeat.times do
    text_block << Faker::Lorem.paragraph(sentence_count: sentences)
    text_block << random
  end
  text_block.join("\n")
end
table() click to toggle source
# File lib/faker/default/markdown.rb, line 47
def table
  table = []
  3.times do
    table << "#{Lorem.word} | #{Lorem.word} | #{Lorem.word}"
  end
  table.insert(1, '---- | ---- | ----')
  table.join("\n")
end
unordered_list() click to toggle source
# File lib/faker/default/markdown.rb, line 29
def unordered_list
  number = rand(1..10)

  result = []
  number.times do |_i|
    result << "* #{Faker::Lorem.sentence(word_count: 1)} \n"
  end
  result.join('')
end

Private Class Methods

available_methods() click to toggle source
# File lib/faker/default/markdown.rb, line 79
def available_methods
  Markdown.public_methods(false) - Base.methods
end