Class: AnagramSolver::Finder
- Inherits:
-
Object
- Object
- AnagramSolver::Finder
- Extended by:
- ActionView::Helpers::TextHelper
- Defined in:
- lib/anagram_solver/finder.rb
Class Attribute Summary collapse
-
.anagrams ⇒ Object
Returns the value of attribute anagrams.
-
.finished_at ⇒ Object
Returns the value of attribute finished_at.
-
.started_at ⇒ Object
Returns the value of attribute started_at.
-
.time ⇒ Object
Returns the value of attribute time.
-
.word ⇒ Object
Returns the value of attribute word.
Class Method Summary collapse
-
.find_for(key, list) ⇒ Object
Finds anagrams for a given key ( i.e word ) and a list, which should be already precomputed.
-
.look_up(list, _word_) ⇒ Object
Look for anagrams.
Class Attribute Details
.anagrams ⇒ Object
Returns the value of attribute anagrams.
16 17 18 |
# File 'lib/anagram_solver/finder.rb', line 16 def anagrams @anagrams end |
.finished_at ⇒ Object
Returns the value of attribute finished_at.
15 16 17 |
# File 'lib/anagram_solver/finder.rb', line 15 def finished_at @finished_at end |
.started_at ⇒ Object
Returns the value of attribute started_at.
15 16 17 |
# File 'lib/anagram_solver/finder.rb', line 15 def started_at @started_at end |
.time ⇒ Object
Returns the value of attribute time.
16 17 18 |
# File 'lib/anagram_solver/finder.rb', line 16 def time @time end |
.word ⇒ Object
Returns the value of attribute word.
16 17 18 |
# File 'lib/anagram_solver/finder.rb', line 16 def word @word end |
Class Method Details
.find_for(key, list) ⇒ Object
Finds anagrams for a given key ( i.e word ) and a list, which should be already precomputed. It returns a JSON object, see anagrams_found!.
28 29 30 31 |
# File 'lib/anagram_solver/finder.rb', line 28 def find_for(key, list) timer { look_up(list, key) } anagrams_found! end |
.look_up(list, _word_) ⇒ Object
Look for anagrams
36 37 38 39 40 |
# File 'lib/anagram_solver/finder.rb', line 36 def look_up(list, _word_) @word = _word_ key = list.sort!(word) @anagrams = list.precomputed_list[key] end |