Class: Dingo
Constant Summary collapse
- DEFAULT_WORD_PATH =
File.(dir + "dingo.txt", __FILE__)
- DEFAULT_PEOPLE_PATH =
File.(dir + "people.txt", __FILE__)
Instance Method Summary collapse
- #emails ⇒ Object
-
#initialize(random: Random.new, source_words: read_file(DEFAULT_WORD_PATH), source_people: read_file(DEFAULT_PEOPLE_PATH), sentence_length: 6, paragraph_length: 4) ⇒ Dingo
constructor
A new instance of Dingo.
- #paragraphs ⇒ Object
- #people ⇒ Object
- #sentences ⇒ Object
- #words ⇒ Object
Constructor Details
#initialize(random: Random.new, source_words: read_file(DEFAULT_WORD_PATH), source_people: read_file(DEFAULT_PEOPLE_PATH), sentence_length: 6, paragraph_length: 4) ⇒ Dingo
Returns a new instance of Dingo.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dingo.rb', line 13 def initialize( random: Random.new, source_words: read_file(DEFAULT_WORD_PATH), source_people: read_file(DEFAULT_PEOPLE_PATH), sentence_length: 6, paragraph_length: 4 ) @random = random @source_words = source_words.select { |w| !w.include?(" ") } @source_people = source_people @all_words = source_words + source_people @sentence_length = sentence_length @paragraph_length = paragraph_length end |
Instance Method Details
#emails ⇒ Object
33 |
# File 'lib/dingo.rb', line 33 def emails; infinite_sequence { email } end |
#paragraphs ⇒ Object
31 |
# File 'lib/dingo.rb', line 31 def paragraphs; infinite_sequence { paragraph } end |
#people ⇒ Object
32 |
# File 'lib/dingo.rb', line 32 def people; infinite_sequence { person } end |
#sentences ⇒ Object
30 |
# File 'lib/dingo.rb', line 30 def sentences; infinite_sequence { sentence } end |
#words ⇒ Object
29 |
# File 'lib/dingo.rb', line 29 def words; infinite_sequence { word } end |