Class: DoctorIpsum::Lorem
Direct Known Subclasses
Class Method Summary collapse
- .paragraph(sentence_count = 5, supplemental = false) ⇒ Object
- .paragraphs(paragraph_count = 5, supplemental = false) ⇒ Object
- .sentence(word_count = 5, supplemental = false, extra_words = 3) ⇒ Object
- .sentences(sentence_count = 5, supplemental = false) ⇒ Object
- .word ⇒ Object
- .words(num = 3, supplemental = false) ⇒ Object
Methods inherited from Base
Class Method Details
.paragraph(sentence_count = 5, supplemental = false) ⇒ Object
25 26 27 |
# File 'lib/doctor_ipsum/lorem.rb', line 25 def paragraph(sentence_count = 5, supplemental = false) sentences(resolve(sentence_count), supplemental) end |
.paragraphs(paragraph_count = 5, supplemental = false) ⇒ Object
28 29 30 31 32 |
# File 'lib/doctor_ipsum/lorem.rb', line 28 def paragraphs(paragraph_count = 5, supplemental = false) [].tap { |p| resolve(paragraph_count).times { p << paragraph(5, supplemental) } }.join("\n\n") end |
.sentence(word_count = 5, supplemental = false, extra_words = 3) ⇒ Object
15 16 17 18 |
# File 'lib/doctor_ipsum/lorem.rb', line 15 def sentence(word_count = 5, supplemental = false, extra_words = 3) num_words = resolve(word_count) + rand(resolve(extra_words)) words(num_words, supplemental).join(' ').capitalize + '.' end |
.sentences(sentence_count = 5, supplemental = false) ⇒ Object
19 20 21 22 23 |
# File 'lib/doctor_ipsum/lorem.rb', line 19 def sentences(sentence_count = 5, supplemental = false) [].tap { |s| resolve(sentence_count).times { s << sentence(5, supplemental) } }.join(' ') end |
.word ⇒ Object
5 6 7 |
# File 'lib/doctor_ipsum/lorem.rb', line 5 def word fetch('lorem.words').sample 1 end |
.words(num = 3, supplemental = false) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/doctor_ipsum/lorem.rb', line 8 def words(num = 3, supplemental = false) ( fetch('lorem.words') + (supplemental ? fetch('lorem.supplemental') : []) ).shuffle[0, resolve(num)] end |