Class: Faker::Markdown

Inherits:
Base
  • Object
show all
Defined in:
lib/faker/markdown.rb

Constant Summary

Constants inherited from Base

Base::Letters, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Base

bothify, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, sample, shuffle, translate, unique, with_locale

Class Method Details

.block_codeObject



42
43
44
# File 'lib/faker/markdown.rb', line 42

def block_code
  "```ruby\n#{Lorem.sentence(1)}\n```"
end

.emphasisObject



9
10
11
12
13
14
15
16
# File 'lib/faker/markdown.rb', line 9

def emphasis
  paragraph = Faker::Lorem.paragraph(3)
  words = paragraph.split(' ')
  position = rand(0..words.length - 1)
  formatting = fetch('markdown.emphasis')
  words[position] = "#{formatting}#{words[position]}#{formatting}"
  words.join(' ')
end

.headersObject



5
6
7
# File 'lib/faker/markdown.rb', line 5

def headers
  "#{fetch('markdown.headers')} #{Lorem.word.capitalize}"
end

.inline_codeObject



38
39
40
# File 'lib/faker/markdown.rb', line 38

def inline_code
  "`#{Faker::Lorem.sentence(1)}`"
end

.ordered_listObject



18
19
20
21
22
23
24
25
26
# File 'lib/faker/markdown.rb', line 18

def ordered_list
  number = rand(1..10)

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

.randomObject



55
56
57
# File 'lib/faker/markdown.rb', line 55

def random
  send(available_methods[rand(0..available_methods.length - 1)])
end

.tableObject



46
47
48
49
50
51
52
53
# File 'lib/faker/markdown.rb', line 46

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

.unordered_listObject



28
29
30
31
32
33
34
35
36
# File 'lib/faker/markdown.rb', line 28

def unordered_list
  number = rand(1..10)

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