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(legacy_number = NOT_GIVEN, number: 1) ⇒ String
-
.location ⇒ String
Produces the name of a location.
-
.paragraph(legacy_sentence_count = NOT_GIVEN, legacy_random_sentences_to_add = NOT_GIVEN, sentence_count: 3, random_sentences_to_add: 3) ⇒ String
Produces a random paragraph.
- .paragraph_by_chars(legacy_characters = NOT_GIVEN, characters: 256) ⇒ String
-
.paragraphs(legacy_number = NOT_GIVEN, number: 3) ⇒ Array<String>
Produces a array of random paragraphs.
-
.sentence(legacy_word_count = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, random_words_to_add: 6) ⇒ String
Produces a random sentence.
-
.sentences(legacy_number = NOT_GIVEN, 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(legacy_number = NOT_GIVEN, legacy_spaces_allowed = NOT_GIVEN, 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, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, translate, unique, with_locale
Class Method Details
.deity ⇒ String
Produces the name of a deity
49 50 51 |
# File 'lib/faker/books/lovecraft.rb', line 49 def deity fetch('lovecraft.deity') end |
.fhtagn(legacy_number = NOT_GIVEN, number: 1) ⇒ String
32 33 34 35 36 37 38 |
# File 'lib/faker/books/lovecraft.rb', line 32 def fhtagn(legacy_number = NOT_GIVEN, number: 1) warn_for_deprecated_arguments do |keywords| keywords << :number if legacy_number != NOT_GIVEN end 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(legacy_sentence_count = NOT_GIVEN, legacy_random_sentences_to_add = NOT_GIVEN, sentence_count: 3, random_sentences_to_add: 3) ⇒ String
Produces a random paragraph
206 207 208 209 210 211 212 213 |
# File 'lib/faker/books/lovecraft.rb', line 206 def paragraph(legacy_sentence_count = NOT_GIVEN, legacy_random_sentences_to_add = NOT_GIVEN, sentence_count: 3, random_sentences_to_add: 3) warn_for_deprecated_arguments do |keywords| keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN keywords << :random_sentences_to_add if legacy_random_sentences_to_add != NOT_GIVEN end sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i).join(' ') end |
.paragraph_by_chars(legacy_characters = NOT_GIVEN, characters: 256) ⇒ String
262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/faker/books/lovecraft.rb', line 262 def paragraph_by_chars(legacy_characters = NOT_GIVEN, characters: 256) warn_for_deprecated_arguments do |keywords| keywords << :characters if legacy_characters != NOT_GIVEN end paragraph = paragraph(sentence_count: 3) paragraph += ' ' + paragraph(sentence_count: 3) while paragraph.length < characters paragraph[0...characters - 1] + '.' end |
.paragraphs(legacy_number = NOT_GIVEN, number: 3) ⇒ Array<String>
Produces a array of random paragraphs
237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/faker/books/lovecraft.rb', line 237 def paragraphs(legacy_number = NOT_GIVEN, number: 3) warn_for_deprecated_arguments do |keywords| keywords << :number if legacy_number != NOT_GIVEN end [].tap do |paragraphs| 1.upto(resolve(number)) do paragraphs << paragraph(sentence_count: 3) end end end |
.sentence(legacy_word_count = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, random_words_to_add: 6) ⇒ String
Produces a random sentence
85 86 87 88 89 90 91 92 |
# File 'lib/faker/books/lovecraft.rb', line 85 def sentence(legacy_word_count = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, random_words_to_add: 6) warn_for_deprecated_arguments do |keywords| keywords << :word_count if legacy_word_count != NOT_GIVEN keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN end words(number: word_count + rand(random_words_to_add.to_i).to_i, spaces_allowed: true).join(' ').capitalize + '.' end |
.sentences(legacy_number = NOT_GIVEN, number: 3) ⇒ Array<String>
Produces a array of random sentences
175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/faker/books/lovecraft.rb', line 175 def sentences(legacy_number = NOT_GIVEN, number: 3) warn_for_deprecated_arguments do |keywords| keywords << :number if legacy_number != NOT_GIVEN end [].tap do |sentences| 1.upto(resolve(number)) do sentences << sentence(word_count: 3) end end end |
.tome ⇒ String
Produces the name of a tome
62 63 64 |
# File 'lib/faker/books/lovecraft.rb', line 62 def tome fetch('lovecraft.tome') end |
.word ⇒ String
Produces a random word
103 104 105 106 |
# File 'lib/faker/books/lovecraft.rb', line 103 def word random_word = sample(translate('faker.lovecraft.words')) random_word =~ /\s/ ? word : random_word end |
.words(legacy_number = NOT_GIVEN, legacy_spaces_allowed = NOT_GIVEN, number: 3, spaces_allowed: false) ⇒ Array<String>
Produces a array of random words
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/faker/books/lovecraft.rb', line 137 def words(legacy_number = NOT_GIVEN, legacy_spaces_allowed = NOT_GIVEN, number: 3, spaces_allowed: false) warn_for_deprecated_arguments do |keywords| keywords << :number if legacy_number != NOT_GIVEN keywords << :spaces_allowed if legacy_spaces_allowed != NOT_GIVEN end resolved_num = resolve(number) word_list = translate('faker.lovecraft.words') word_list *= ((resolved_num / word_list.length) + 1) return shuffle(word_list)[0, resolved_num] if spaces_allowed words = shuffle(word_list)[0, resolved_num] words.each_with_index { |w, i| words[i] = word if w =~ /\s/ } end |