Class: Dingo

Inherits:
Object
  • Object
show all
Extended by:
SingleForwardable
Defined in:
lib/dingo.rb

Constant Summary collapse

DEFAULT_WORD_PATH =
File.expand_path(dir + "dingo.txt", __FILE__)
DEFAULT_PEOPLE_PATH =
File.expand_path(dir + "people.txt", __FILE__)

Instance Method Summary collapse

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

#emailsObject



33
# File 'lib/dingo.rb', line 33

def emails;     infinite_sequence { email } end

#paragraphsObject



31
# File 'lib/dingo.rb', line 31

def paragraphs; infinite_sequence { paragraph } end

#peopleObject



32
# File 'lib/dingo.rb', line 32

def people;     infinite_sequence { person } end

#sentencesObject



30
# File 'lib/dingo.rb', line 30

def sentences;  infinite_sequence { sentence } end

#wordsObject



29
# File 'lib/dingo.rb', line 29

def words;      infinite_sequence { word } end