Class: Faker::Markdown
- Inherits:
-
Base
- Object
- Base
- Faker::Markdown
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, respond_to_missing?, sample, shuffle, translate, unique, with_locale
Class Method Details
.block_code ⇒ Object
41
42
43
|
# File 'lib/faker/markdown.rb', line 41
def block_code
"```ruby\n#{Lorem.sentence(1)}\n```"
end
|
.emphasis ⇒ Object
8
9
10
11
12
13
14
15
|
# File 'lib/faker/markdown.rb', line 8
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
|
4
5
6
|
# File 'lib/faker/markdown.rb', line 4
def
"#{fetch('markdown.headers')} #{Lorem.word.capitalize}"
end
|
.inline_code ⇒ Object
37
38
39
|
# File 'lib/faker/markdown.rb', line 37
def inline_code
"`#{Faker::Lorem.sentence(1)}`"
end
|
.ordered_list ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'lib/faker/markdown.rb', line 17
def ordered_list
number = rand(1..10)
result = []
number.times do |i|
result << "#{i}. #{Faker::Lorem.sentence(1)} \n"
end
result.join('')
end
|
.random ⇒ Object
54
55
56
|
# File 'lib/faker/markdown.rb', line 54
def random
send(available_methods[rand(0..available_methods.length - 1)])
end
|
.sandwich(sentences = 3, repeat = 1) ⇒ Object
58
59
60
61
62
63
64
65
66
|
# File 'lib/faker/markdown.rb', line 58
def sandwich(sentences = 3, repeat = 1)
text_block = []
text_block <<
repeat.times do
text_block << Faker::Lorem.paragraph(sentences)
text_block << random
end
text_block.join("\n")
end
|
.table ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'lib/faker/markdown.rb', line 45
def table
table = []
3.times do
table << "#{Lorem.word} | #{Lorem.word} | #{Lorem.word}"
end
table.insert(1, '---- | ---- | ----')
table.join("\n")
end
|
.unordered_list ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'lib/faker/markdown.rb', line 27
def unordered_list
number = rand(1..10)
result = []
number.times do |_i|
result << "* #{Faker::Lorem.sentence(1)} \n"
end
result.join('')
end
|