class PersonalFaker::Base
Attributes
file[RW]
table[RW]
text[RW]
Public Class Methods
new(choose_text)
click to toggle source
# File lib/personal_faker.rb, line 9 def initialize(choose_text) if choose_text == 'dr-seuss' @file = 'lib/personal_faker/texts/dr-seuss.rtf' elsif choose_text == 'pride-and-prejudice' @file = 'lib/personal_faker/texts/pride-and-prejudice.rtf' elsif choose_text == 'macbeth' @file = 'lib/personal_faker/texts/macbeth.rtf' end end
Public Instance Methods
question()
click to toggle source
# File lib/personal_faker.rb, line 62 def question word = table.keys.sample.capitalize sentence = word 10.times do if table[word] word = table[word].sample else word = table.keys.sample end sentence = sentence + " " + word end sentence = sentence + "?" end
sentence()
click to toggle source
# File lib/personal_faker.rb, line 48 def sentence word = table.keys.sample.capitalize sentence = word 10.times do if table[word] word = table[word].sample else word = table.keys.sample end sentence = sentence + " " + word end sentence = sentence + "." end
text_phrase(count)
click to toggle source
# File lib/personal_faker.rb, line 80 def text_phrase(count) phrase = sentence (count - 1).times do phrase << " " + sentence end phrase end
word()
click to toggle source
# File lib/personal_faker.rb, line 76 def word word = table.keys.sample end