class LastFM::Query

Public Class Methods

get_info(args={}) click to toggle source

Query.get_info(‘album.get_info’, artist, album)

# File lib/last_fm/query.rb, line 28
def get_info(args={})
  parsed_results = retrieve_from_api(args)
  if parsed_results['album']
    Album.new(parsed_results['album'])
  else
    nil
  end
end
retrieve_from_api(args={}) click to toggle source
# File lib/last_fm/query.rb, line 4
def retrieve_from_api(args={})
  response = connection.get('/2.0/', {
    api_key: LastFM.api_key,
    format: 'json'
  }.merge(args))

  parsed_results = JSON.parse(response.body)
end

Protected Class Methods

connection() click to toggle source
# File lib/last_fm/query.rb, line 38
def connection
  conn ||= Faraday.new(url: 'http://ws.audioscrobbler.com') do |faraday|
    faraday.request :url_encoded
    faraday.adapter Faraday.default_adapter
  end
end