Class: MarkovTextGenerator::Api::Model::Knowledge::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/markov_text_generator/api/model/knowledge/entry.rb

Instance Method Summary collapse

Constructor Details

#initialize(word, random_generator = RandomProxy.new) ⇒ Entry



16
17
18
19
20
# File 'lib/markov_text_generator/api/model/knowledge/entry.rb', line 16

def initialize(word, random_generator = RandomProxy.new)
  @current_word = word
  @random_generator = random_generator
  @next_words = []
end

Instance Method Details

#add_next_word(word) ⇒ Object



22
23
24
# File 'lib/markov_text_generator/api/model/knowledge/entry.rb', line 22

def add_next_word(word)
  @next_words.push word
end

#predict_next_wordObject



26
27
28
# File 'lib/markov_text_generator/api/model/knowledge/entry.rb', line 26

def predict_next_word
  @next_words[random_pick]
end

#to_sObject



30
31
32
# File 'lib/markov_text_generator/api/model/knowledge/entry.rb', line 30

def to_s
  @current_word
end