Class: ThatLanguage::ResultSet
- Inherits:
-
Object
- Object
- ThatLanguage::ResultSet
- Includes:
- Enumerable
- Defined in:
- lib/that_language/result_set.rb
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #for(key) ⇒ Object
-
#initialize(words_count) ⇒ ResultSet
constructor
A new instance of ResultSet.
- #results ⇒ Object
- #to_h ⇒ Object
- #to_json ⇒ Object
- #winner ⇒ Object
Constructor Details
#initialize(words_count) ⇒ ResultSet
5 6 7 |
# File 'lib/that_language/result_set.rb', line 5 def initialize(words_count) @words_count = words_count end |
Instance Method Details
#each(&block) ⇒ Object
23 24 25 |
# File 'lib/that_language/result_set.rb', line 23 def each(&block) results.each(&block) end |
#for(key) ⇒ Object
9 10 11 |
# File 'lib/that_language/result_set.rb', line 9 def for(key) lookup[key] end |
#results ⇒ Object
17 18 19 20 21 |
# File 'lib/that_language/result_set.rb', line 17 def results finalize_results _results.sort.reverse end |
#to_h ⇒ Object
27 28 29 30 31 |
# File 'lib/that_language/result_set.rb', line 27 def to_h { results: results.map(&:to_h) } end |
#to_json ⇒ Object
33 34 35 |
# File 'lib/that_language/result_set.rb', line 33 def to_json to_h.to_json end |
#winner ⇒ Object
13 14 15 |
# File 'lib/that_language/result_set.rb', line 13 def winner results.max end |