Class: MusicBrainz::Webservice::ReleaseGroupFilter

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

Overview

A filter for the release group collection.

Instance Method Summary collapse

Methods inherited from AbstractFilter

#to_s

Constructor Details

#initialize(filter) ⇒ ReleaseGroupFilter

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 release groups with a matching title. [:artist] The returned release groups should match the given artist name. [:artistid] The returned releasegroups should match the given artist ID (36 character ASCII representation). If this is given, the artist parameter is ignored. [:releasetypes] The returned release groups must match all of the given release types. This is either an array of release types as defined in Model::ReleaseGroup or a string of space separated values like Official, Bootleg, Album, Compilation etc. [:limit] The maximum number of release groups 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.



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/rbrainz/webservice/filter.rb', line 98

def initialize(filter)
  Utils.check_options filter, 
    :limit, :offset, :query, :title, :artist, :artistid, :releasetypes
  super(filter)
  @filter[:title]        = filter[:title]     if filter[:title]
  @filter[:artist]       = filter[:artist]    if filter[:artist]
  @filter[:artistid]     = filter[:artistid]  if filter[:artistid]
  
  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