Class: Kotoshu::PersonalDictionary
- Inherits:
-
Object
- Object
- Kotoshu::PersonalDictionary
- Defined in:
- lib/kotoshu/personal_dictionary.rb
Overview
Personal dictionary for user-specific words.
Stored in ~/.config/kotoshu/personal.dic (Hunspell format) under the XDG config directory. Override via KOTOSHU_PERSONAL_DIC.
Constant Summary collapse
- PERSONAL_FILE =
Kotoshu::Paths.personal_dictionary_path
Class Method Summary collapse
-
.add_word(word) ⇒ Boolean
Add a word to personal dictionary.
-
.include?(word) ⇒ Boolean
Check if word is in personal dictionary.
-
.remove_word(word) ⇒ Boolean
Remove a word from personal dictionary.
-
.words ⇒ Array<String>
Get all personal words.
Class Method Details
.add_word(word) ⇒ Boolean
Add a word to personal dictionary.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/kotoshu/personal_dictionary.rb', line 18 def add_word(word) return false if word.nil? || word.empty? ensure_directory words = load_words unless words.include?(word.downcase) words << word.downcase save_words(words) end true end |
.include?(word) ⇒ Boolean
Check if word is in personal dictionary.
59 60 61 62 63 |
# File 'lib/kotoshu/personal_dictionary.rb', line 59 def include?(word) return false if word.nil? || word.empty? load_words.include?(word.downcase) end |
.remove_word(word) ⇒ Boolean
Remove a word from personal dictionary.
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/kotoshu/personal_dictionary.rb', line 43 def remove_word(word) return false if word.nil? || word.empty? words = load_words if words.delete(word.downcase) save_words(words) true else false end end |
.words ⇒ Array<String>
Get all personal words.
35 36 37 |
# File 'lib/kotoshu/personal_dictionary.rb', line 35 def words load_words end |