Class: LyricsSearch::SearchResults

Inherits:
Object
  • Object
show all
Defined in:
lib/lyrics_search/search_results.rb

Defined Under Namespace

Classes: SearchResult

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result, search_type) ⇒ SearchResults

Returns a new instance of SearchResults.



6
7
8
9
10
11
# File 'lib/lyrics_search/search_results.rb', line 6

def initialize(result, search_type)
  results = result.dig((search_type + '_response').to_sym, (search_type + '_result').to_sym, :search_lyric_result).
                   compact.select{|res| !res[:lyric_id].to_i.zero?}
  
  results.inject(@results = []){|results, result| results << SearchResult.new(result)} if results
end

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results.



4
5
6
# File 'lib/lyrics_search/search_results.rb', line 4

def results
  @results
end