Class: Faker::Books::Lovecraft

Inherits:
Faker::Base show all
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

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

.deityString

Produces the name of a deity

Examples:

Faker::Books::Lovecraft.deity #=> "Shub-Niggurath"

Returns:



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

Examples:

Faker::Books::Lovecraft.fhtagn
  #=> "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn"
Faker::Books::Lovecraft.fhtagn(number: 3)
  #=> "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fht...

Parameters:

  • number (Integer) (defaults to: 1)

    The number of times to repeat the chant

Returns:



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

.locationString

Produces the name of a location

Examples:

Faker::Books::Lovecraft.location #=> "Kingsport"

Returns:



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

Examples:

Faker::Books::Lovecraft.paragraph
  #=> "Squamous nameless daemoniac fungus ululate. Cyclopean stygian decadent loathsome manuscript tenebrous. Foetid abnormal stench. Dank non-euclidean comprehension eldritch. Charnel singular shunned lurk effulgence fungus."
Faker::Books::Lovecraft.paragraph(sentence_count: 2)
  #=> "Decadent lurk tenebrous loathsome furtive spectral amorphous gibbous. Gambrel eldritch daemoniac cat madness comprehension stygian effulgence."
Faker::Books::Lovecraft.paragraph(sentence_count: 1, random_sentences_to_add: 1)
  #=> "Stench cyclopean fainted antiquarian nameless. Antiquarian ululate tenebrous non-euclidean effulgence."

Parameters:

  • sentence_count (Integer) (defaults to: 3)

    Number of sentences to generate

  • random_sentences_to_add (Integer) (defaults to: 3)

Returns:



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

Examples:

Faker::Books::Lovecraft.paragraph_by_chars
  #=> "Truffaut stumptown trust fund 8-bit messenger bag portland. Meh kombucha selvage swag biodiesel. Lomo kinfolk jean shorts asymmetrical diy. Wayfarers portland twee stumptown. Wes anderson biodiesel retro 90's pabst. Diy echo 90's mixtape semiotics. Cornho."
Faker::Books::Lovecraft.paragraph_by_chars(characters: 128)
  #=> "Effulgence madness noisome. Fungus stygian mortal madness amorphous dank. Decadent noisome hideous effulgence. Tentacles charne."

Parameters:

  • characters (Integer) (defaults to: 256)

    Number of characters to generate in the paragraph

Returns:



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

Examples:

Faker::Books::Lovecraft.paragraphs
#=> [
#     "Noisome daemoniac gibbous abnormal antediluvian. Unutterable fung...
#     "Non-euclidean immemorial indescribable accursed furtive. Dank unn...
#     "Charnel antediluvian unnamable cat blasphemous comprehension tene...
#   ]
Faker::Books::Lovecraft.paragraphs(number: 2)
#=> [
#     "Hideous amorphous manuscript antediluvian non-euclidean cat eldri...
#     "Tenebrous unnamable comprehension antediluvian lurk. Lurk spectra...
#   ]

Parameters:

  • number (Integer) (defaults to: 3)

    Number of paragraphs to generate

Returns:



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

Examples:

Faker::Books::Lovecraft.sentence
  #=> "Furtive antiquarian squamous dank cat loathsome amorphous lurk."
Faker::Books::Lovecraft.sentence(word_count: 3)
  #=> "Daemoniac antediluvian fainted squamous comprehension gambrel nameless singular."
Faker::Books::Lovecraft.sentence(word_count: 3, random_words_to_add: 1)
  #=> "Amorphous indescribable tenebrous."

Parameters:

  • word_count (Integer) (defaults to: 4)

    The number of words to have in the sentence

  • random_words_to_add (Integer) (defaults to: 6)

Returns:



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

Examples:

Faker::Books::Lovecraft.sentences
#=> [
#     "Nameless loathsome decadent gambrel.",
#     "Ululate swarthy immemorial cat madness gibbous unmentionable unnamable.",
#     "Decadent antediluvian non-euclidean tentacles amorphous tenebrous.",
#   ]
Faker::Books::Lovecraft.sentences(number: 2)
#=> [
#     "Antediluvian amorphous unmentionable singular accursed squamous immemorial.",
#     "Gambrel daemoniac gibbous stygian shunned ululate iridescence abnormal.",
#   ]

Parameters:

  • number (Integer) (defaults to: 3)

    Number of sentences to generate

Returns:



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

.tomeString

Produces the name of a tome

Examples:

Faker::Books::Lovecraft.tome #=> "Book of Eibon"

Returns:



62
63
64
# File 'lib/faker/books/lovecraft.rb', line 62

def tome
  fetch('lovecraft.tome')
end

.wordString

Produces a random word

Examples:

Faker::Books::Lovecraft.word #=> "furtive"

Returns:



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

Examples:

Faker::Books::Lovecraft.words
#=> [
#     "manuscript",
#     "abnormal",
#     "singular",
#   ]
Faker::Books::Lovecraft.words(number: 2)
#=> [
#     "daemoniac",
#     "cat",
#   ]
Faker::Books::Lovecraft.words(number: 2, spaces_allowed: 1)
#=> [
#     "lurk",
#     "charnel",
#   ]

Parameters:

  • number (Integer) (defaults to: 3)

    Number of words to generate

  • spaces_allowed (Boolean) (defaults to: false)

    If true, generated words can contain spaces

Returns:



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