Class: LastFm::User
- Inherits:
-
Base
show all
- Defined in:
- lib/last_fm/models/user.rb
Instance Method Summary
collapse
Methods inherited from Base
#attributes=, create_from_hash, #get_xml_attributes, #method_missing, #methods, #name, #name=, search
Constructor Details
#initialize(name) ⇒ User
Returns a new instance of User.
4
5
6
|
# File 'lib/last_fm/models/user.rb', line 4
def initialize(name)
super(name)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class LastFm::Base
Instance Method Details
#top_albums ⇒ Object
14
15
16
17
18
|
# File 'lib/last_fm/models/user.rb', line 14
def top_albums
lfm_path = "user.gettopalbums&user=#{@name}"
lfm_data = LastFm::fetch_data(lfm_path)
return Album.create_from_hash(Hash.from_xml(lfm_data)['lfm']['topalbums']['album'])
end
|
#top_artists ⇒ Object
27
28
29
30
31
|
# File 'lib/last_fm/models/user.rb', line 27
def top_artists
lfm_path = "user.gettopartists&user=#{@name}"
lfm_data = LastFm::fetch_data(lfm_path)
return Artist.create_from_hash(Hash.from_xml(lfm_data)['lfm']['topartists']['artist'])
end
|
#weekly_album_chart ⇒ Object
8
9
10
11
12
|
# File 'lib/last_fm/models/user.rb', line 8
def weekly_album_chart
lfm_path = "user.weeklyalbumchart&user=#{@name}"
lfm_data = LastFm::fetch_data(lfm_path)
return Album.create_from_hash(Hash.from_xml(lfm_data)['lfm']['weeklyalbumchart']['album'])
end
|
#weekly_artists_chart ⇒ Object
21
22
23
24
25
|
# File 'lib/last_fm/models/user.rb', line 21
def weekly_artists_chart
lfm_path = "user.getweeklyartistchart&user=#{@name}"
lfm_data = LastFm::fetch_data(lfm_path)
return Artist.create_from_hash(Hash.from_xml(lfm_data)['lfm']['weeklyartistchart']['artist'])
end
|