Class: ActiveKit::Search::SuggestionResult
- Inherits:
-
Object
- Object
- ActiveKit::Search::SuggestionResult
- Defined in:
- lib/active_kit/search/suggestion_result.rb
Instance Attribute Summary collapse
-
#documents ⇒ Object
readonly
Returns the value of attribute documents.
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#scores ⇒ Object
readonly
Returns the value of attribute scores.
Instance Method Summary collapse
-
#initialize(prefix:, results:) ⇒ SuggestionResult
constructor
A new instance of SuggestionResult.
Constructor Details
#initialize(prefix:, results:) ⇒ SuggestionResult
Returns a new instance of SuggestionResult.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/active_kit/search/suggestion_result.rb', line 6 def initialize(prefix:, results:) @prefix = prefix if results @documents = results.each_slice(2).map { |key, value| [key, value] }.to_h @keys = @documents.keys @scores = @documents.values else @documents = {} @keys = [] @scores = [] end end |
Instance Attribute Details
#documents ⇒ Object (readonly)
Returns the value of attribute documents.
4 5 6 |
# File 'lib/active_kit/search/suggestion_result.rb', line 4 def documents @documents end |
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
4 5 6 |
# File 'lib/active_kit/search/suggestion_result.rb', line 4 def keys @keys end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
4 5 6 |
# File 'lib/active_kit/search/suggestion_result.rb', line 4 def prefix @prefix end |
#scores ⇒ Object (readonly)
Returns the value of attribute scores.
4 5 6 |
# File 'lib/active_kit/search/suggestion_result.rb', line 4 def scores @scores end |