Class: Faker::Books::Lovecraft
- Inherits:
-
Faker::Base
- Object
- Faker::Base
- Faker::Books::Lovecraft
- Defined in:
- lib/faker/books/lovecraft.rb
Constant Summary
Constants inherited from Faker::Base
Faker::Base::LLetters, Faker::Base::Letters, Faker::Base::NOT_GIVEN, Faker::Base::Numbers, Faker::Base::ULetters
Class Method Summary collapse
-
.deity ⇒ String
Produces the name of a deity.
- .fhtagn(number: 1) ⇒ String
-
.location ⇒ String
Produces the name of a location.
-
.paragraph(sentence_count: 3, random_sentences_to_add: 3) ⇒ String
Produces a random paragraph.
- .paragraph_by_chars(characters: 256) ⇒ String
-
.paragraphs(number: 3) ⇒ Array<String>
Produces a array of random paragraphs.
-
.sentence(word_count: 4, random_words_to_add: 6, open_compounds_allowed: true) ⇒ String
Produces a random sentence.
-
.sentences(number: 3) ⇒ Array<String>
Produces a array of random sentences.
-
.tome ⇒ String
Produces the name of a tome.
-
.word ⇒ String
Produces a random word.
-
.words(number: 3, spaces_allowed: false) ⇒ Array<String>
Produces a array of random words.
Methods inherited from Faker::Base
bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, generate, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, shuffle!, translate, unique, with_locale
Class Method Details
.deity ⇒ String
Produces the name of a deity
45 46 47 |
# File 'lib/faker/books/lovecraft.rb', line 45 def deity fetch('lovecraft.deity') end |
.fhtagn(number: 1) ⇒ String
32 33 34 |
# File 'lib/faker/books/lovecraft.rb', line 32 def fhtagn(number: 1) Array.new(number) { fetch('lovecraft.fhtagn') }.join('. ') end |
.location ⇒ String
Produces the name of a location
16 17 18 |
# File 'lib/faker/books/lovecraft.rb', line 16 def location fetch('lovecraft.location') end |
.paragraph(sentence_count: 3, random_sentences_to_add: 3) ⇒ String
Produces a random paragraph
191 192 193 |
# File 'lib/faker/books/lovecraft.rb', line 191 def paragraph(sentence_count: 3, random_sentences_to_add: 3) sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i).join(' ') end |
.paragraph_by_chars(characters: 256) ⇒ String
238 239 240 241 242 243 244 |
# File 'lib/faker/books/lovecraft.rb', line 238 def paragraph_by_chars(characters: 256) paragraph = paragraph(sentence_count: 3) paragraph += " #{paragraph(sentence_count: 3)}" while paragraph.length < characters "#{paragraph[0...characters - 1]}." end |
.paragraphs(number: 3) ⇒ Array<String>
Produces a array of random paragraphs
217 218 219 220 221 222 223 |
# File 'lib/faker/books/lovecraft.rb', line 217 def paragraphs(number: 3) [].tap do |paragraphs| 1.upto(resolve(number)) do paragraphs << paragraph(sentence_count: 3) end end end |
.sentence(word_count: 4, random_words_to_add: 6, open_compounds_allowed: true) ⇒ String
Produces a random sentence
85 86 87 |
# File 'lib/faker/books/lovecraft.rb', line 85 def sentence(word_count: 4, random_words_to_add: 6, open_compounds_allowed: true) "#{words(number: word_count + rand(random_words_to_add.to_i).to_i, spaces_allowed: open_compounds_allowed).join(' ').capitalize}." end |
.sentences(number: 3) ⇒ Array<String>
Produces a array of random sentences
164 165 166 167 168 169 170 |
# File 'lib/faker/books/lovecraft.rb', line 164 def sentences(number: 3) [].tap do |sentences| 1.upto(resolve(number)) do sentences << sentence(word_count: 3) end end end |
.tome ⇒ String
Produces the name of a tome
58 59 60 |
# File 'lib/faker/books/lovecraft.rb', line 58 def tome fetch('lovecraft.tome') end |
.word ⇒ String
Produces a random word
98 99 100 101 |
# File 'lib/faker/books/lovecraft.rb', line 98 def word random_word = sample(translate('faker.lovecraft.words')) random_word =~ /\s/ ? word : random_word end |
.words(number: 3, spaces_allowed: false) ⇒ Array<String>
Produces a array of random words
132 133 134 135 136 137 138 139 140 |
# File 'lib/faker/books/lovecraft.rb', line 132 def words(number: 3, spaces_allowed: false) resolved_num = resolve(number) word_list = translate('faker.lovecraft.words') word_list *= ((resolved_num / word_list.length) + 1) words = sample(word_list, resolved_num) return words if spaces_allowed words.each_with_index { |w, i| words[i] = word if w =~ /\s/ } end |