Class: PersonalFaker::Base
- Inherits:
-
Object
- Object
- PersonalFaker::Base
- Defined in:
- lib/personal_faker.rb,
lib/personal_faker/base.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#table ⇒ Object
Returns the value of attribute table.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(choose_text) ⇒ Base
constructor
A new instance of Base.
- #question ⇒ Object
- #sentence ⇒ Object
Constructor Details
#initialize(choose_text) ⇒ Base
Returns a new instance of Base.
9 10 11 12 13 14 15 16 17 |
# 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 |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
7 8 9 |
# File 'lib/personal_faker.rb', line 7 def file @file end |
#table ⇒ Object
Returns the value of attribute table.
5 6 7 |
# File 'lib/personal_faker.rb', line 5 def table @table end |
#text ⇒ Object
Returns the value of attribute text.
6 7 8 |
# File 'lib/personal_faker.rb', line 6 def text @text end |
Instance Method Details
#question ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# 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 ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# 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 |