Class: Faker::Lorem
Overview
Based on Perl’s Text::Lorem
Class Method Summary
collapse
Methods inherited from Base
bothify, fetch, flexible, letterify, method_missing, numerify, parse, translate
Class Method Details
.characters(char_count = 255) ⇒ Object
11
12
13
|
# File 'lib/faker/lorem.rb', line 11
def self.characters(char_count = 255)
rand(36**char_count).to_s(36)
end
|
.paragraph(sentence_count = 3, supplemental = false) ⇒ Object
27
28
29
|
# File 'lib/faker/lorem.rb', line 27
def self.paragraph(sentence_count = 3, supplemental = false)
sentences(sentence_count + rand(3), supplemental).join(' ')
end
|
.paragraphs(paragraph_count = 3, supplemental = false) ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/faker/lorem.rb', line 31
def self.paragraphs(paragraph_count = 3, supplemental = false)
[].tap do |paragraphs|
1.upto(paragraph_count) do
paragraphs << paragraph(3, supplemental)
end
end
end
|
.sentence(word_count = 4, supplemental = false) ⇒ Object
15
16
17
|
# File 'lib/faker/lorem.rb', line 15
def self.sentence(word_count = 4, supplemental = false)
words(word_count + rand(6), supplemental).join(' ').capitalize + '.'
end
|
.sentences(sentence_count = 3, supplemental = false) ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/faker/lorem.rb', line 19
def self.sentences(sentence_count = 3, supplemental = false)
[].tap do |sentences|
1.upto(sentence_count) do
sentences << sentence(3, supplemental)
end
end
end
|
.words(num = 3, supplemental = false) ⇒ Object
4
5
6
7
8
9
|
# File 'lib/faker/lorem.rb', line 4
def self.words(num = 3, supplemental = false)
(
translate('faker.lorem.words') +
(supplemental ? translate('faker.lorem.supplemental') : [])
).shuffle[0, num]
end
|