Class: Wordle::List
- Inherits:
-
Object
- Object
- Wordle::List
- Defined in:
- lib/wordle/list.rb
Instance Method Summary collapse
Instance Method Details
#by_hash(hash) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/wordle/list.rb', line 9 def by_hash(hash) word = list.detect do |word| Digest::SHA2.hexdigest(word.downcase.strip)[..5] == hash end raise Wordle::Error, "Invalid word identifier, are you sure you copied it correctly?" if word.nil? word end |
#invalid?(word) ⇒ Boolean
19 20 21 |
# File 'lib/wordle/list.rb', line 19 def invalid?(word) !list.include?(word) end |
#random ⇒ Object
5 6 7 |
# File 'lib/wordle/list.rb', line 5 def random list.sample.downcase.strip end |