class ScrabbleScore::WordFinder
Public Class Methods
new(dictionary = ScrabbleScore::Dictionary.new)
click to toggle source
# File lib/scrabble_score/word_finder.rb, line 3 def initialize(dictionary = ScrabbleScore::Dictionary.new) @dictionary = dictionary end
Public Instance Methods
search(letters)
click to toggle source
# File lib/scrabble_score/word_finder.rb, line 7 def search(letters) permutations = ScrabbleScore::Letters.new(letters).permutations permutations.select! { |perm| @dictionary.contains(perm) } end
search_with_score(letters)
click to toggle source
# File lib/scrabble_score/word_finder.rb, line 12 def search_with_score(letters) found_words = search(letters) hash = {} found_words.each do |word| hash[word] = ScrabbleScore::Letters.new(word).score end hash end