Class: UnderFire::AlbumFetch

Inherits:
BaseQuery show all
Defined in:
lib/under_fire/album_fetch.rb

Overview

Builds XML for Gracenote’s ALBUM_FETCH query.

Examples:

search = UnderFire::Album_Fetch.new(:gn_id => '86372321-2C7F28ADC369EB90E53A7F6CA3A70D56')
search.query => Response = The Beatles, Help!

See Also:

Instance Attribute Summary collapse

Attributes inherited from BaseQuery

#config, #mode

Instance Method Summary collapse

Methods inherited from BaseQuery

#build_base_query

Constructor Details

#initialize(args) ⇒ AlbumFetch

Requires album :gn_id or track :gn_id

Parameters:

  • args (Hash)

    the arguments for Album_Fetch

Options Hash (args):

  • :gn_id (String)

    Gracenote ID of album or track

  • :mode (String)

    Either ‘SINGLE_BEST’ or ‘SINGLE_BEST_COVER’ (Only needed if track :gn_id used)



28
29
30
31
32
33
# File 'lib/under_fire/album_fetch.rb', line 28

def initialize(args)
  super args
  @parameters = args.reject {|k,v| k == :mode}
  parameters.each do |k,v| send("#{k}=", v) end
  @query = build_query
end

Instance Attribute Details

#gn_idString

Returns Gracenote ID for album.

Returns:

  • (String)

    Gracenote ID for album



20
21
22
# File 'lib/under_fire/album_fetch.rb', line 20

def gn_id
  @gn_id
end

#parametersHash (readonly)

Returns Search parameters with :mode removed.

Returns:

  • (Hash)

    Search parameters with :mode removed.



17
18
19
# File 'lib/under_fire/album_fetch.rb', line 17

def parameters
  @parameters
end

#queryString (readonly)

Returns XML string for query.

Returns:

  • (String)

    XML string for query.



14
15
16
# File 'lib/under_fire/album_fetch.rb', line 14

def query
  @query
end

Instance Method Details

#build_queryString

Builds ALBUM_FETCH-specific part of ALBUM_FETCH query and adds it to the base query common to all query types. Called by constructor.

Returns:

  • (String)

    XML string for ALBUM_FETCH query.



39
40
41
42
43
44
45
46
47
48
# File 'lib/under_fire/album_fetch.rb', line 39

def build_query
  build_base_query do |builder|
    builder.QUERY(cmd: "ALBUM_FETCH"){
      builder.MODE "SINGLE_BEST_COVER"
      parameters.each do |k,v|
        builder.GN_ID gn_id
      end
    }
  end
end