Class: InMemorySolutionsHandler
- Inherits:
-
Object
- Object
- InMemorySolutionsHandler
- Defined in:
- lib/raramorph/in_memory_solutions_handler.rb
Constant Summary collapse
- @@handler =
nil
Class Method Summary collapse
Instance Method Summary collapse
-
#add_alternative_spellings(translitered, alt) ⇒ Object
Add alternative spellings for the given word * [translitered] The translitered word * [alt] The alternative spelling.
-
#add_solutions(translitered, sol) ⇒ Object
Add solutions for a given word * [translitered] The translitered word.
-
#get_alternative_spellings(translitered) ⇒ Object
Return the alternative spellings of the word * [translitered] The translitered word * @return The alternative spellings matching the transliterd word.
-
#get_solutions(translitered) ⇒ Object
Return the solutions of a given word * [translitered] The translitered word * @return The solution matching the transliterd word.
-
#has_alternative_spellings(translitered) ⇒ Object
Whether or not the word already gave alternative spellings * [translitered] The translitered word * @return If the transliterd word has alternative spellings.
-
#has_solutions(translitered) ⇒ Object
Whether or not the word already gave solutions * [translitered] The translitered word * @return If it has the solution or not (Boolean).
Class Method Details
.create ⇒ Object
14 15 16 17 |
# File 'lib/raramorph/in_memory_solutions_handler.rb', line 14 def self.create @@handler= new unless @@handler @@handler end |
Instance Method Details
#add_alternative_spellings(translitered, alt) ⇒ Object
Add alternative spellings for the given word
- translitered
-
The translitered word
- alt
-
The alternative spelling
49 50 51 |
# File 'lib/raramorph/in_memory_solutions_handler.rb', line 49 def add_alternative_spellings(translitered, alt) @@alternative_spellings[translitered] = alt end |
#add_solutions(translitered, sol) ⇒ Object
Add solutions for a given word
- translitered
-
The translitered word.
- sol
-
The solution to the translitered word.
24 25 26 |
# File 'lib/raramorph/in_memory_solutions_handler.rb', line 24 def add_solutions (translitered, sol) @@solutions[translitered] = sol end |
#get_alternative_spellings(translitered) ⇒ Object
Return the alternative spellings of the word
- translitered
-
The translitered word
-
@return The alternative spellings matching the transliterd word.
63 64 65 66 67 68 69 |
# File 'lib/raramorph/in_memory_solutions_handler.rb', line 63 def get_alternative_spellings(translitered) if(self.has_alternative_spellings(translitered)) return @@alternative_spellings[translitered] else return nil end end |
#get_solutions(translitered) ⇒ Object
Return the solutions of a given word
- translitered
-
The translitered word
-
@return The solution matching the transliterd word.
38 39 40 41 42 43 44 |
# File 'lib/raramorph/in_memory_solutions_handler.rb', line 38 def get_solutions(translitered) if(self.has_solutions(translitered)) return @@solutions[translitered] else return nil end end |
#has_alternative_spellings(translitered) ⇒ Object
Whether or not the word already gave alternative spellings
- translitered
-
The translitered word
-
@return If the transliterd word has alternative spellings
56 57 58 |
# File 'lib/raramorph/in_memory_solutions_handler.rb', line 56 def has_alternative_spellings(translitered) @@alternative_spellings.has_key?(translitered) end |
#has_solutions(translitered) ⇒ Object
Whether or not the word already gave solutions
- translitered
-
The translitered word
-
@return If it has the solution or not (Boolean).
31 32 33 |
# File 'lib/raramorph/in_memory_solutions_handler.rb', line 31 def has_solutions(translitered) @@solutions.has_key?(translitered) end |