Class: Faker::Lovecraft

Inherits:
Base
  • Object
show all
Defined in:
lib/faker/lovecraft.rb

Constant Summary

Constants inherited from Base

Base::Letters, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Base

bothify, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, sample, shuffle, translate, unique, with_locale

Class Method Details

.deityObject



12
13
14
# File 'lib/faker/lovecraft.rb', line 12

def deity
  fetch('lovecraft.deity')
end

.fhtagn(number_of = 1) ⇒ Object



8
9
10
# File 'lib/faker/lovecraft.rb', line 8

def fhtagn(number_of = 1)
  number_of.times.collect { fetch('lovecraft.fhtagn') }.join(". ")
end

.locationObject



4
5
6
# File 'lib/faker/lovecraft.rb', line 4

def location
  fetch('lovecraft.location')
end

.paragraph(sentence_count = 3, random_sentences_to_add = 3) ⇒ Object



48
49
50
# File 'lib/faker/lovecraft.rb', line 48

def paragraph(sentence_count = 3, random_sentences_to_add = 3)
  sentences(resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i).join(' ')
end

.paragraphs(paragraph_count = 3) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/faker/lovecraft.rb', line 52

def paragraphs(paragraph_count = 3)
  [].tap do |paragraphs|
    1.upto(resolve(paragraph_count)) do
      paragraphs << paragraph(3)
    end
  end
end

.sentence(word_count = 4, random_words_to_add = 6) ⇒ Object



20
21
22
# File 'lib/faker/lovecraft.rb', line 20

def sentence(word_count = 4, random_words_to_add = 6)
  words(word_count + rand(random_words_to_add.to_i).to_i, true).join(' ').capitalize + '.'
end

.sentences(sentence_count = 3) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/faker/lovecraft.rb', line 40

def sentences(sentence_count = 3)
  [].tap do |sentences|
    1.upto(resolve(sentence_count)) do
      sentences << sentence(3)
    end
  end
end

.tomeObject



16
17
18
# File 'lib/faker/lovecraft.rb', line 16

def tome
  fetch('lovecraft.tome')
end

.wordObject



24
25
26
27
# File 'lib/faker/lovecraft.rb', line 24

def word
  random_word = sample(translate('faker.lovecraft.words'))
  random_word.match(/\s/) ? word : random_word
end

.words(num = 3, spaces_allowed = false) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/faker/lovecraft.rb', line 29

def words(num = 3, spaces_allowed = false)
  resolved_num = resolve(num)
  word_list = translate('faker.lovecraft.words')
  word_list = 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.match(/\s/) }
end