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, sample, shuffle, translate, unique, with_locale
Class Method Details
.block_code ⇒ Object
42
43
44
|
# File 'lib/faker/markdown.rb', line 42
def block_code
"```ruby\n#{Lorem.sentence(1)}\n```"
end
|
.emphasis ⇒ Object
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
|
5
6
7
|
# File 'lib/faker/markdown.rb', line 5
def
"#{fetch('markdown.headers')} #{Lorem.word.capitalize}"
end
|
.inline_code ⇒ Object
38
39
40
|
# File 'lib/faker/markdown.rb', line 38
def inline_code
"`#{Faker::Lorem.sentence(1)}`"
end
|
.ordered_list ⇒ Object
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
|
.random ⇒ Object
55
56
57
|
# File 'lib/faker/markdown.rb', line 55
def random
send(available_methods[rand(0..available_methods.length - 1)])
end
|
.table ⇒ Object
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_list ⇒ Object
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
|