Class: UnderFire::AlbumSearch
- Defined in:
- lib/under_fire/album_search.rb
Overview
Builds XML for Gracenote’s ALBUM_SEARCH query.
Instance Attribute Summary collapse
- #album_title ⇒ String
- #artist ⇒ String
-
#parameters ⇒ Hash
readonly
Search parameters without :mode.
-
#query ⇒ String
readonly
XML string for query.
- #track_title ⇒ String
Attributes inherited from BaseQuery
Instance Method Summary collapse
-
#build_query ⇒ String
Builds ALBUM_SEARCH-specific part of ALBUM_SEARCH query and adds it to the base query common to all query types.
-
#initialize(args = {}) ⇒ AlbumSearch
constructor
At least one of :artist, :track_title, :album_title is required (:mode is optional).
Methods inherited from BaseQuery
Constructor Details
#initialize(args = {}) ⇒ AlbumSearch
At least one of :artist, :track_title, :album_title is required (:mode is optional).
42 43 44 45 46 47 |
# 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 |
Instance Attribute Details
#album_title ⇒ String
33 34 35 |
# File 'lib/under_fire/album_search.rb', line 33 def album_title @album_title end |
#artist ⇒ String
27 28 29 |
# File 'lib/under_fire/album_search.rb', line 27 def artist @artist end |
#parameters ⇒ Hash (readonly)
Returns search parameters without :mode.
24 25 26 |
# File 'lib/under_fire/album_search.rb', line 24 def parameters @parameters end |
#query ⇒ String (readonly)
Returns XML string for query.
21 22 23 |
# File 'lib/under_fire/album_search.rb', line 21 def query @query end |
#track_title ⇒ String
30 31 32 |
# File 'lib/under_fire/album_search.rb', line 30 def track_title @track_title end |
Instance Method Details
#build_query ⇒ String
Builds ALBUM_SEARCH-specific part of ALBUM_SEARCH query and adds it to the base query common to all query types. Called by constructor.
53 54 55 56 57 58 59 60 61 62 |
# 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 |