Class: WordleDecoder::Guess
- Inherits:
-
Object
- Object
- WordleDecoder::Guess
- Defined in:
- lib/wordle_decoder/guess.rb
Instance Method Summary collapse
- #best_words_with_scores ⇒ Object
-
#initialize(start_word, first_word_position, word_positions) ⇒ Guess
constructor
A new instance of Guess.
- #inspect ⇒ Object
- #score ⇒ Object
- #word_scores ⇒ Object
- #words ⇒ Object
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_scores ⇒ Object
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 |
#inspect ⇒ Object
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 |
#score ⇒ Object
11 12 13 |
# File 'lib/wordle_decoder/guess.rb', line 11 def score @score ||= best_words_with_scores.sum(&:last) end |
#word_scores ⇒ Object
15 16 17 |
# File 'lib/wordle_decoder/guess.rb', line 15 def word_scores @word_scores ||= best_words_with_scores.map(&:last) end |
#words ⇒ Object
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 |