Module: Kotoshu::Dictionary
- Defined in:
- lib/kotoshu/dictionary.rb,
lib/kotoshu/dictionary/base.rb,
lib/kotoshu/dictionary/cspell.rb,
lib/kotoshu/dictionary/custom.rb,
lib/kotoshu/dictionary/unified.rb,
lib/kotoshu/dictionary/hunspell.rb,
lib/kotoshu/dictionary/plain_text.rb,
lib/kotoshu/dictionary/repository.rb,
lib/kotoshu/dictionary/unix_words.rb
Overview
Dictionary backends for different formats (Hunspell, CSpell, plain text, etc.).
Defined Under Namespace
Classes: Base, CSpell, Custom, Hunspell, PlainText, Repository, Unified, UnixWords
Class Method Summary collapse
-
.load(type, *args) ⇒ Base
Load a dictionary by type.
-
.register_type(type, klass) ⇒ Object
Register a dictionary type.
-
.registry ⇒ Hash
Module-level registry for dictionary types.
-
.reset_registry! ⇒ void
Reset the type registry.
Class Method Details
.load(type, *args) ⇒ Base
Load a dictionary by type.
264 265 266 267 268 269 |
# File 'lib/kotoshu/dictionary/base.rb', line 264 def self.load(type, *args) klass = registry[type] raise ConfigurationError, "Unknown dictionary type: #{type}" unless klass klass.new(*args) end |
.register_type(type, klass) ⇒ Object
Register a dictionary type.
250 251 252 253 |
# File 'lib/kotoshu/dictionary/base.rb', line 250 def self.register_type(type, klass) @registry ||= {} @registry[type] = klass end |
.registry ⇒ Hash
Module-level registry for dictionary types.
231 232 233 |
# File 'lib/kotoshu/dictionary/base.rb', line 231 def self.registry @registry ||= {} end |
.reset_registry! ⇒ void
This method returns an undefined value.
Reset the type registry. Used by specs that register throw-away dictionary classes; not part of the runtime contract.
239 240 241 |
# File 'lib/kotoshu/dictionary/base.rb', line 239 def self.reset_registry! @registry = {} end |