Based on Perl’s Text::Lorem
# File lib/faker/lorem.rb, line 16 def characters(char_count = 255) return '' if char_count.respond_to?(:to_i) && char_count.to_i < 1 char_count = resolve(char_count) rand(36**char_count).to_s(36).rjust(char_count, '0').chars.to_a.shuffle.join end
# File lib/faker/lorem.rb, line 34 def paragraph(sentence_count = 3, supplemental = false) sentences(resolve(sentence_count) + rand(3), supplemental).join(' ') end
# File lib/faker/lorem.rb, line 38 def paragraphs(paragraph_count = 3, supplemental = false) [].tap do |paragraphs| 1.upto(resolve(paragraph_count)) do paragraphs << paragraph(3, supplemental) end end end
# File lib/faker/lorem.rb, line 22 def sentence(word_count = 4, supplemental = false) words(word_count + rand(6), supplemental).join(' ').capitalize + '.' end
# File lib/faker/lorem.rb, line 26 def sentences(sentence_count = 3, supplemental = false) [].tap do |sentences| 1.upto(resolve(sentence_count)) do sentences << sentence(3, supplemental) end end end
# File lib/faker/lorem.rb, line 5 def word translate('faker.lorem.words').sample end
# File lib/faker/lorem.rb, line 9 def words(num = 3, supplemental = false) ( translate('faker.lorem.words') + (supplemental ? translate('faker.lorem.supplemental') : []) ).shuffle[0, resolve(num)] end