class UnderFire::AlbumSearch
Builds XML for Gracenote's ALBUM_SEARCH query.
@example
search = UnderFire::AlbumSearch.new(:artist => 'Radiohead') search.query #=> XML for Gracenote ALBUM_SEARCH query for albums by Radiohead. search = UnderFire::AlbumSearch.new(:track_title = > 'Paranoid Android', :artist => 'Radiohead', :mode => 'SINGLE_BEST_COVER') search.query #=> XML for ALBUM_SEARCH
Attributes
album_title[RW]
@return [String]
artist[RW]
@return [String]
parameters[R]
@return [Hash] search parameters without :mode
query[R]
@return [String] XML string for query.
track_title[RW]
@return [String]
Public Class Methods
new(args={})
click to toggle source
At least one of :artist, :track_title, :album_title is required (:mode is optional).
@param [Hash] args the arguments for an Album_Search. @option args [String] :artist Name of the artist. @option args [String] :track_title Name of the song/track. @option args [String] :album_title Name of the album. @option args [String] :mode Either 'SINGLE_BEST' or 'SINGLE_BEST_COVER'
Calls superclass method
# File lib/under_fire/album_search.rb, line 42 def initialize(args={}) super args[:mode] @parameters = args.reject {|k,v| k == :mode} parameters.each do |k,v| send("#{k}=", v) end @query = build_query end
Public Instance Methods
build_query()
click to toggle source
Builds ALBUM_SEARCH-specific part of ALBUM_SEARCH query and adds it to the base query common to all query types. Called by constructor.
@return [String] XML string for ALBUM_SEARCH query.
# File lib/under_fire/album_search.rb, line 53 def build_query build_base_query do |builder| builder.QUERY(CMD: "ALBUM_SEARCH"){ builder.MODE "SINGLE_BEST_COVER" parameters.each do |k,v| builder.TEXT(v, TYPE: k.to_s.upcase) end } end end