Class: NameSearch::SearchResult

Inherits:
Object
  • Object
show all
Defined in:
lib/name_search/search_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_matchesObject (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_scoreObject (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_namesObject (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

#modelObject (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_matchesObject (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