Class: Discogs::Search

Inherits:
Base
  • Object
show all
Defined in:
lib/search.rb

Constant Summary

Constants inherited from Base

Base::DISCOGS_BASE_URL

Instance Attribute Summary collapse

Attributes inherited from Base

#api_key, #request_string, #request_type

Instance Method Summary collapse

Methods inherited from Base

#fetched, #parsed

Constructor Details

#initialize(request_string) ⇒ Search

Returns a new instance of Search.



10
11
12
13
14
# File 'lib/search.rb', line 10

def initialize(request_string)
  @request_string = request_string
  @search_type = 'all' # search_type doesn't seem to make any difference as of API v 1.0
  super
end

Instance Attribute Details

#exactresult_sizeObject

size of exact search phrase matches



17
18
19
# File 'lib/search.rb', line 17

def exactresult_size
  @exactresult_size
end

#exactresultsObject

results that match the search phrase exactly



27
28
29
# File 'lib/search.rb', line 27

def exactresults
  @exactresults
end

#result_sizeObject

size of fuzzy matches



22
23
24
# File 'lib/search.rb', line 22

def result_size
  @result_size
end

#resultsObject

fuzzy results



39
40
41
# File 'lib/search.rb', line 39

def results
  @results
end

#search_typeObject

Returns the value of attribute search_type.



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

def search_type
  @search_type
end

Instance Method Details

#best_matchObject

use the exact results to get more data using another api call based on the result type



52
53
54
55
56
57
58
# File 'lib/search.rb', line 52

def best_match
  first_result = exactresults.first
  if first_result.artist?
    artist = Discogs::Artist.new(api_key, first_result.title)
    artist.releases[0,5]
  end
end