Class: NameSearch::SearchResult
- Inherits:
-
Object
- Object
- NameSearch::SearchResult
- Defined in:
- lib/name_search/search_result.rb
Instance Attribute Summary collapse
-
#exact_name_matches ⇒ Object
readonly
Returns the value of attribute exact_name_matches.
-
#match_score ⇒ Object
readonly
Returns the value of attribute match_score.
-
#matched_names ⇒ Object
readonly
Returns the value of attribute matched_names.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#nick_name_matches ⇒ Object
readonly
Returns the value of attribute nick_name_matches.
Instance Method Summary collapse
-
#initialize(model, searched_names, searched_nick_names) ⇒ SearchResult
constructor
A new instance of SearchResult.
Constructor Details
#initialize(model, searched_names, searched_nick_names) ⇒ SearchResult
Returns a new instance of SearchResult.
5 6 7 8 9 10 11 12 |
# File 'lib/name_search/search_result.rb', line 5 def initialize(model, searched_names, searched_nick_names) @model = model @exact_name_matches = model.name_searchable_values & searched_names @nick_name_matches = model.name_searchable_values & searched_nick_names @matched_names = @exact_name_matches + @nick_name_matches @match_score = (@exact_name_matches.length * 4) + (@nick_name_matches.length * 3) end |
Instance Attribute Details
#exact_name_matches ⇒ Object (readonly)
Returns the value of attribute exact_name_matches.
3 4 5 |
# File 'lib/name_search/search_result.rb', line 3 def exact_name_matches @exact_name_matches end |
#match_score ⇒ Object (readonly)
Returns the value of attribute match_score.
3 4 5 |
# File 'lib/name_search/search_result.rb', line 3 def match_score @match_score end |
#matched_names ⇒ Object (readonly)
Returns the value of attribute matched_names.
3 4 5 |
# File 'lib/name_search/search_result.rb', line 3 def matched_names @matched_names end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
3 4 5 |
# File 'lib/name_search/search_result.rb', line 3 def model @model end |
#nick_name_matches ⇒ Object (readonly)
Returns the value of attribute nick_name_matches.
3 4 5 |
# File 'lib/name_search/search_result.rb', line 3 def nick_name_matches @nick_name_matches end |