Class: Faker::Books::Lovecraft
Constant Summary
Constants inherited
from Faker::Base
Faker::Base::Letters, 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
.deity ⇒ Object
15
16
17
|
# File 'lib/faker/books/lovecraft.rb', line 15
def deity
fetch('lovecraft.deity')
end
|
.fhtagn(number_of = 1) ⇒ Object
11
12
13
|
# File 'lib/faker/books/lovecraft.rb', line 11
def fhtagn(number_of = 1)
Array.new(number_of) { fetch('lovecraft.fhtagn') }.join('. ')
end
|
.location ⇒ Object
7
8
9
|
# File 'lib/faker/books/lovecraft.rb', line 7
def location
fetch('lovecraft.location')
end
|
.paragraph(sentence_count = 3, random_sentences_to_add = 3) ⇒ Object
51
52
53
|
# File 'lib/faker/books/lovecraft.rb', line 51
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
|
.paragraph_by_chars(chars = 256) ⇒ Object
63
64
65
66
67
68
69
|
# File 'lib/faker/books/lovecraft.rb', line 63
def paragraph_by_chars(chars = 256)
paragraph = paragraph(3)
paragraph += ' ' + paragraph(3) while paragraph.length < chars
paragraph[0...chars - 1] + '.'
end
|
.paragraphs(paragraph_count = 3) ⇒ Object
55
56
57
58
59
60
61
|
# File 'lib/faker/books/lovecraft.rb', line 55
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
23
24
25
|
# File 'lib/faker/books/lovecraft.rb', line 23
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
43
44
45
46
47
48
49
|
# File 'lib/faker/books/lovecraft.rb', line 43
def sentences(sentence_count = 3)
[].tap do |sentences|
1.upto(resolve(sentence_count)) do
sentences << sentence(3)
end
end
end
|
.tome ⇒ Object
19
20
21
|
# File 'lib/faker/books/lovecraft.rb', line 19
def tome
fetch('lovecraft.tome')
end
|
.word ⇒ Object
27
28
29
30
|
# File 'lib/faker/books/lovecraft.rb', line 27
def word
random_word = sample(translate('faker.lovecraft.words'))
random_word =~ /\s/ ? word : random_word
end
|
.words(num = 3, spaces_allowed = false) ⇒ Object
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/faker/books/lovecraft.rb', line 32
def words(num = 3, spaces_allowed = false)
resolved_num = resolve(num)
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
|