Class: MusicBrainz::Webservice::AbstractFilter
- Inherits:
-
Object
- Object
- MusicBrainz::Webservice::AbstractFilter
- Defined in:
- lib/rbrainz/webservice/filter.rb
Overview
Base class for all filter classes.
Filter classes are initialized with a set of criteria and are then applied to collections of items. The criteria are usually strings or integer values, depending on the filter.
Direct Known Subclasses
ArtistFilter, LabelFilter, ReleaseFilter, ReleaseGroupFilter, TrackFilter
Instance Method Summary collapse
-
#initialize(filter) ⇒ AbstractFilter
constructor
The parameter filter is a hash with filter options.
-
#to_s ⇒ Object
Returns the filter list as a query string (without leading &).
Constructor Details
#initialize(filter) ⇒ AbstractFilter
The parameter filter is a hash with filter options. See the concrete classes for a description of those options.
The following options are available for all filters:
- :limit
-
The maximum number of entries 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 musicbrainz.org/doc/TextSearchSyntax.
34 35 36 37 38 39 |
# File 'lib/rbrainz/webservice/filter.rb', line 34 def initialize(filter) @filter = Hash.new @filter[:limit] = filter[:limit] if filter[:limit] @filter[:offset] = filter[:offset] if filter[:offset] @filter[:query] = filter[:query] if filter[:query] end |
Instance Method Details
#to_s ⇒ Object
Returns the filter list as a query string (without leading &).
42 43 44 45 46 |
# File 'lib/rbrainz/webservice/filter.rb', line 42 def to_s @filter.to_a.map {|name, value| '%s=%s' % [CGI.escape(name.to_s), CGI.escape(value.to_s)] }.join('&') end |