Class: LastFm::Album
Class Method Summary collapse
Instance Method Summary collapse
- #info(artist, options = {}) ⇒ Object
-
#initialize(artist, name) ⇒ Album
constructor
A new instance of Album.
Methods inherited from Base
#attributes=, create_from_hash, #get_xml_attributes, #method_missing, #methods, #name, #name=
Constructor Details
#initialize(artist, name) ⇒ Album
Returns a new instance of Album.
4 5 6 7 8 |
# File 'lib/last_fm/models/album.rb', line 4 def initialize(artist,name) super(name) @attributes = self.info(artist) if @attributes == {} and !artist.blank? _process_attributes end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class LastFm::Base
Class Method Details
.search(artist, album) ⇒ Object
18 19 20 |
# File 'lib/last_fm/models/album.rb', line 18 def self.search(artist,album) self.new(artist,album) end |
Instance Method Details
#info(artist, options = {}) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/last_fm/models/album.rb', line 10 def info(artist, = {}) params = "" .each_pair { |key,value| params += "&#{key}=#{value}" } lfm_path = "album.getinfo&artist=#{artist}&album=#{@name}#{params}" lfm_data = LastFm::fetch_data(lfm_path) return Hash.from_xml(lfm_data)['lfm']['album'] end |