Class: ActiveLastfm

Inherits:
ActiveResource::Base show all
Defined in:
lib/active_lastfm.rb

Overview

This abstract base-class extends ActiveResource::Base to make requests to last.fm Based largely on the ActiveYouTube examples found at:

Class Method Summary collapse

Methods inherited from ActiveResource::Base

#load

Class Method Details

.collection_path(prefix_options = {}, query_options = nil) ⇒ Object

Remove format from the url.



22
23
24
25
# File 'lib/active_lastfm.rb', line 22

def collection_path(prefix_options = {}, query_options = nil)
  prefix_options, query_options = split_options(prefix_options) if query_options.nil?
  "#{prefix(prefix_options)}#{query_string(query_options)}"
end

.element_path(id, prefix_options = {}, query_options = nil) ⇒ Object

Remove format from the url.



16
17
18
19
# File 'lib/active_lastfm.rb', line 16

def element_path(id, prefix_options = {}, query_options = nil)
  prefix_options, query_options = split_options(prefix_options) if query_options.nil?
  "#{prefix(prefix_options)}#{query_string(query_options)}"
end

.instantiate_collection(collection, prefix_options = {}) ⇒ Object

For a collection call, ActiveResource formatting is not compliant with YouTube’s output.



29
30
31
32
33
34
35
36
# File 'lib/active_lastfm.rb', line 29

def instantiate_collection(collection, prefix_options = {})
  puts collection.inspect
  unless collection.kind_of? Array
    [instantiate_record(collection, prefix_options)]
  else
    collection.collect! { |record| instantiate_record(record, prefix_options) }
  end
end