Class: WordleDecoder::Guess

Inherits:
Object
  • Object
show all
Defined in:
lib/wordle_decoder/guess.rb

Instance Method Summary collapse

Constructor Details

#initialize(start_word, first_word_position, word_positions) ⇒ Guess

Returns a new instance of Guess.



5
6
7
8
9
# File 'lib/wordle_decoder/guess.rb', line 5

def initialize(start_word, first_word_position, word_positions)
  @start_word = start_word
  @first_word_position = first_word_position
  @word_positions = word_positions
end

Instance Method Details

#best_words_with_scoresObject



23
24
25
# File 'lib/wordle_decoder/guess.rb', line 23

def best_words_with_scores
  @best_words_with_scores ||= select_best_words_with_scores
end

#inspectObject



27
28
29
# File 'lib/wordle_decoder/guess.rb', line 27

def inspect
  "<#{self.class.name} score: #{score}, word_scores: #{word_scores}, words: #{words}>"
end

#scoreObject



11
12
13
# File 'lib/wordle_decoder/guess.rb', line 11

def score
  @score ||= best_words_with_scores.sum(&:last)
end

#word_scoresObject



15
16
17
# File 'lib/wordle_decoder/guess.rb', line 15

def word_scores
  @word_scores ||= best_words_with_scores.map(&:last)
end

#wordsObject



19
20
21
# File 'lib/wordle_decoder/guess.rb', line 19

def words
  @words ||= best_words_with_scores.map { |w, _s| w.to_s }
end