Class: MusicBrainz::Webservice::ReleaseFilter

Inherits:
AbstractFilter show all
Defined in:
lib/rbrainz/webservice/filter.rb

Overview

A filter for the release collection.

Instance Method Summary collapse

Methods inherited from AbstractFilter

#to_s

Constructor Details

#initialize(filter) ⇒ ReleaseFilter

The parameter filter is a hash with filter options. At least one filter despite :limit and :offset must be specified.

Available filter options: [:title] Fetch a list of releases with a matching title. [:discid] Fetch all releases matching to the given DiscID. [:artist] The returned releases should match the given artist name. [:artistid] The returned releases should match the given artist ID (36 character ASCII representation). If this is given, the artist parameter is ignored. [:releasetypes] The returned releases must match all of the given release types. This is either an array of release types as defined in Model::Release or a string of space separated values like Official, Bootleg, Album, Compilation etc. [:count] Number of tracks in the release. [:date] Earliest release date for the release. [:asin] The Amazon ASIN. [:lang] The language for this release. [:script] The script used in this release. [:cdstubs] Flag which indicates whether to include CD stubs or not (boolean). Defaults to false. [:limit] The maximum number of releases returned. Defaults to 25, the maximum allowed value is 100. [:offset] Return search results starting at a given offset. Used for paging through more than one page of results. [:query] A Lucene search query. The query parameter is a search string which will be passed to the underlying Lucene search engine. It must follow the syntax described in http://musicbrainz.org/doc/TextSearchSyntax.



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/rbrainz/webservice/filter.rb', line 150

def initialize(filter)
  Utils.check_options filter, 
    :limit, :offset, :query, :title, :discid, :artist, :artistid, 
    :releasetypes, :count, :date, :asin, :lang, :script, :cdstubs
  super(filter)
  @filter[:title]        = filter[:title]     if filter[:title]
  @filter[:discid]       = filter[:discid]    if filter[:discid]
  @filter[:artist]       = filter[:artist]    if filter[:artist]
  @filter[:artistid]     = filter[:artistid]  if filter[:artistid]
  @filter[:count]        = filter[:count]     if filter[:count]
  @filter[:date]         = filter[:date]      if filter[:date]
  @filter[:asin]         = filter[:asin]      if filter[:asin]
  @filter[:lang]         = filter[:lang]      if filter[:lang]
  @filter[:script]       = filter[:script]    if filter[:script]
  
  @filter[:cdstubs] = filter[:cdstubs] ? 'yes' : 'no'
  
  if releasetypes = filter[:releasetypes]
    if releasetypes.respond_to?(:to_a)
      releasetypes = releasetypes.to_a.map do |type|
        Utils.remove_namespace(type)
      end.join(' ')
    end
    @filter[:releasetypes] = releasetypes
  end
end