Class: Rlastfm::Artist
Class Method Summary
collapse
Instance Method Summary
collapse
add_mapped_reader, add_reader, memoize_method, remote_reader
included
Constructor Details
#initialize(name) ⇒ Artist
Returns a new instance of Artist.
21
22
23
24
|
# File 'lib/rlastfm/artist.rb', line 21
def initialize(name)
self.class.default_params :api_key => Rlastfm.api_key
@initialized_name = name
end
|
Class Method Details
.top_twenty ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'lib/rlastfm/artist.rb', line 12
def self.top_twenty
doc = doc_for("/charts/artist")
top_twenty = doc.at('.mediumImageChart')
top_twenty.search('tr').map do |artist_row|
name = artist_row.search('.subject < a').last
new name
end
end
|
Instance Method Details
#album_by_name(album_name) ⇒ Object
26
27
28
|
# File 'lib/rlastfm/artist.rb', line 26
def album_by_name(album_name)
albums.detect {|a| a.name == album_name}
end
|
#albums ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/rlastfm/artist.rb', line 30
def albums
@albums ||= begin
response = self.class.get('', :query => {:method => "artist.gettopalbums", :artist => name})
album_collection = response['lfm']['topalbums']['album']
album_collection.map{|album_attrs| Album.new album_attrs} if album_collection
end
end
|
#exists? ⇒ Boolean
38
39
40
|
# File 'lib/rlastfm/artist.rb', line 38
def exists?
! mbid.nil?
end
|
#raw ⇒ Object
42
43
44
|
# File 'lib/rlastfm/artist.rb', line 42
def raw
@raw ||= remote_sync!
end
|
#similar_artists ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/rlastfm/artist.rb', line 46
def similar_artists
@similar_artists ||= begin
raw['similar']['artist'].map do |artist|
Artist.new artist['name']
end
end
end
|