Class: Discogs::Search

Inherits:
Resource show all
Defined in:
lib/wrapper/resources/search.rb

Overview

Represents a search resultset in the Discogs API.

Defined Under Namespace

Classes: Result

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#build!, #build_with_resp!, #initialize, #original_content

Methods included from ResourceMappings

included

Constructor Details

This class inherits a constructor from Discogs::Resource

Instance Attribute Details

#endObject

Returns the value of attribute end.



7
8
9
# File 'lib/wrapper/resources/search.rb', line 7

def end
  @end
end

#exactresultsObject

Returns the value of attribute exactresults.



7
8
9
# File 'lib/wrapper/resources/search.rb', line 7

def exactresults
  @exactresults
end

#numResultsObject

Returns the value of attribute numResults.



7
8
9
# File 'lib/wrapper/resources/search.rb', line 7

def numResults
  @numResults
end

#searchresultsObject

Returns the value of attribute searchresults.



7
8
9
# File 'lib/wrapper/resources/search.rb', line 7

def searchresults
  @searchresults
end

#startObject

Returns the value of attribute start.



7
8
9
# File 'lib/wrapper/resources/search.rb', line 7

def start
  @start
end

Instance Method Details

#closest(filter) ⇒ Object

Returns the closest exact result for filter, or nil.



38
39
40
# File 'lib/wrapper/resources/search.rb', line 38

def closest(filter)
  exact(filter)[0] rescue nil
end

#current_pageObject



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

def current_page
  (start.to_i / page_size) + 1
end

#exact(filter = nil) ⇒ Object



29
30
31
# File 'lib/wrapper/resources/search.rb', line 29

def exact(filter=nil)
  filter_results(filter, self.exactresults)
end

#last_page?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/wrapper/resources/search.rb', line 25

def last_page?
  current_page == total_pages
end

#results(filter = nil) ⇒ Object



33
34
35
# File 'lib/wrapper/resources/search.rb', line 33

def results(filter=nil)
  filter_results(filter, self.searchresults)
end

#total_pagesObject



21
22
23
# File 'lib/wrapper/resources/search.rb', line 21

def total_pages
  (total_results.to_f / page_size).ceil
end

#total_resultsObject



13
14
15
# File 'lib/wrapper/resources/search.rb', line 13

def total_results
  self.numResults.to_i
end