Class: Faker::Lorem
Overview
Based on Perl’s Text::Lorem
Class Method Summary
collapse
Methods inherited from Base
bothify, fetch, letterify, numerify
Class Method Details
.paragraph(sentence_count = 3) ⇒ Object
20
21
22
|
# File 'lib/faker/lorem.rb', line 20
def self.paragraph(sentence_count = 3)
sentences(sentence_count + rand(3)).join(' ')
end
|
.paragraphs(paragraph_count = 3) ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/faker/lorem.rb', line 24
def self.paragraphs(paragraph_count = 3)
[].tap do |paragraphs|
1.upto(paragraph_count) do
paragraphs << paragraph
end
end
end
|
.sentence(word_count = 4) ⇒ Object
8
9
10
|
# File 'lib/faker/lorem.rb', line 8
def self.sentence(word_count = 4)
words(word_count + rand(6)).join(' ').capitalize + '.'
end
|
.sentences(sentence_count = 3) ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/faker/lorem.rb', line 12
def self.sentences(sentence_count = 3)
[].tap do |sentences|
1.upto(sentence_count) do
sentences << sentence
end
end
end
|
.words(num = 3) ⇒ Object
4
5
6
|
# File 'lib/faker/lorem.rb', line 4
def self.words(num = 3)
I18n.translate('faker.lorem.words').shuffle[0, num]
end
|