Class: AlfonsoX::SpellChecker::Dictionary::WordList
- Inherits:
-
Object
- Object
- AlfonsoX::SpellChecker::Dictionary::WordList
- Defined in:
- lib/alfonsox/spellchecker/dictionary/word_list.rb
Overview
Custom dictionary loader composed by a word list
Instance Attribute Summary collapse
-
#words ⇒ Object
readonly
Returns the value of attribute words.
Class Method Summary collapse
-
.from_config(yml_config) ⇒ Object
Load from Yml.
Instance Method Summary collapse
-
#initialize(word_list) ⇒ WordList
constructor
Initialize a AlfonsoX::SpellChecker::Dictionary::WordList.
-
#word_present?(word) ⇒ Boolean
Inform if a word is present in this dictionary.
Constructor Details
#initialize(word_list) ⇒ WordList
Initialize a AlfonsoX::SpellChecker::Dictionary::WordList
15 16 17 |
# File 'lib/alfonsox/spellchecker/dictionary/word_list.rb', line 15 def initialize(word_list) @words = word_list.map(&:downcase) end |
Instance Attribute Details
#words ⇒ Object (readonly)
Returns the value of attribute words.
11 12 13 |
# File 'lib/alfonsox/spellchecker/dictionary/word_list.rb', line 11 def words @words end |
Class Method Details
.from_config(yml_config) ⇒ Object
Load from Yml
20 21 22 |
# File 'lib/alfonsox/spellchecker/dictionary/word_list.rb', line 20 def self.from_config(yml_config) new(yml_config.fetch('word_list') { [] }) end |
Instance Method Details
#word_present?(word) ⇒ Boolean
Inform if a word is present in this dictionary.
25 26 27 |
# File 'lib/alfonsox/spellchecker/dictionary/word_list.rb', line 25 def word_present?(word) @words.include?(word.downcase) end |