Class: CodewordsSolver::Dictionary
- Inherits:
-
Object
- Object
- CodewordsSolver::Dictionary
- Includes:
- ActiveSupport::Inflector
- Defined in:
- lib/codewords_solver/dictionary.rb
Constant Summary collapse
- DEFAULT_FILEPATH =
File.join(__dir__, "..", "..", "word_list.txt")
Instance Method Summary collapse
- #find_by_regexp(regexp) ⇒ Object
- #has?(word) ⇒ Boolean
-
#initialize ⇒ Dictionary
constructor
A new instance of Dictionary.
- #load! ⇒ Object (also: #reload!)
Constructor Details
#initialize ⇒ Dictionary
Returns a new instance of Dictionary.
9 10 11 |
# File 'lib/codewords_solver/dictionary.rb', line 9 def initialize load! end |
Instance Method Details
#find_by_regexp(regexp) ⇒ Object
13 14 15 |
# File 'lib/codewords_solver/dictionary.rb', line 13 def find_by_regexp(regexp) @words.filter { |w| w.length > 2 and w.match? regexp } end |
#has?(word) ⇒ Boolean
17 18 19 |
# File 'lib/codewords_solver/dictionary.rb', line 17 def has?(word) @words.include? word end |
#load! ⇒ Object Also known as: reload!
21 22 23 |
# File 'lib/codewords_solver/dictionary.rb', line 21 def load! @words = import_words_by_filepath(DEFAULT_FILEPATH) end |