Class: Scrobbler::Artist
Instance Attribute Summary collapse
-
#chartposition ⇒ Object
Returns the value of attribute chartposition.
-
#count ⇒ Object
Returns the value of attribute count.
-
#image ⇒ Object
Returns the value of attribute image.
-
#match ⇒ Object
used for similar artists.
-
#mbid ⇒ Object
Returns the value of attribute mbid.
-
#name ⇒ Object
Returns the value of attribute name.
-
#playcount ⇒ Object
Returns the value of attribute playcount.
-
#rank ⇒ Object
Returns the value of attribute rank.
-
#reach ⇒ Object
Returns the value of attribute reach.
-
#streamable ⇒ Object
Returns the value of attribute streamable.
-
#thumbnail ⇒ Object
Returns the value of attribute thumbnail.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #api_path ⇒ Object
- #current_events(format = :ics) ⇒ Object
-
#initialize(name) ⇒ Artist
constructor
A new instance of Artist.
- #similar(force = false) ⇒ Object
- #top_albums(force = false) ⇒ Object
- #top_fans(force = false) ⇒ Object
- #top_tags(force = false) ⇒ Object
- #top_tracks(force = false) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(name) ⇒ Artist
Returns a new instance of Artist.
92 93 94 95 |
# File 'lib/scrobbler/artist.rb', line 92 def initialize(name) raise ArgumentError, "Name is required" if name.blank? @name = name end |
Instance Attribute Details
#chartposition ⇒ Object
Returns the value of attribute chartposition.
62 63 64 |
# File 'lib/scrobbler/artist.rb', line 62 def chartposition @chartposition end |
#count ⇒ Object
Returns the value of attribute count.
61 62 63 |
# File 'lib/scrobbler/artist.rb', line 61 def count @count end |
#image ⇒ Object
Returns the value of attribute image.
61 62 63 |
# File 'lib/scrobbler/artist.rb', line 61 def image @image end |
#match ⇒ Object
used for similar artists
65 66 67 |
# File 'lib/scrobbler/artist.rb', line 65 def match @match end |
#mbid ⇒ Object
Returns the value of attribute mbid.
61 62 63 |
# File 'lib/scrobbler/artist.rb', line 61 def mbid @mbid end |
#name ⇒ Object
Returns the value of attribute name.
61 62 63 |
# File 'lib/scrobbler/artist.rb', line 61 def name @name end |
#playcount ⇒ Object
Returns the value of attribute playcount.
61 62 63 |
# File 'lib/scrobbler/artist.rb', line 61 def playcount @playcount end |
#rank ⇒ Object
Returns the value of attribute rank.
61 62 63 |
# File 'lib/scrobbler/artist.rb', line 61 def rank @rank end |
#reach ⇒ Object
Returns the value of attribute reach.
61 62 63 |
# File 'lib/scrobbler/artist.rb', line 61 def reach @reach end |
#streamable ⇒ Object
Returns the value of attribute streamable.
61 62 63 |
# File 'lib/scrobbler/artist.rb', line 61 def streamable @streamable end |
#thumbnail ⇒ Object
Returns the value of attribute thumbnail.
61 62 63 |
# File 'lib/scrobbler/artist.rb', line 61 def thumbnail @thumbnail end |
#url ⇒ Object
Returns the value of attribute url.
61 62 63 |
# File 'lib/scrobbler/artist.rb', line 61 def url @url end |
Class Method Details
.new_from_xml(xml, doc = nil) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/scrobbler/artist.rb', line 68 def new_from_xml(xml, doc=nil) name = (xml).at(:name).inner_html if (xml).at(:name) # occasionally name can be found in root of artist element (<artist name="">) rather than as an element (<name>) name = xml['name'] if name.nil? && xml['name'] a = Artist.new(name) a.mbid = (xml).at(:mbid).inner_html if (xml).at(:mbid) a.playcount = (xml).at(:playcount).inner_html if (xml).at(:playcount) a.rank = (xml).at(:rank).inner_html if (xml).at(:rank) a.url = (xml).at(:url).inner_html if (xml).at(:url) a.thumbnail = (xml).at(:thumbnail).inner_html if (xml).at(:thumbnail) a.thumbnail = (xml).at(:image_small).inner_html if a.thumbnail.nil? && (xml).at(:image_small) a.image = (xml).at(:image).inner_html if (xml).at(:image) a.reach = (xml).at(:reach).inner_html if (xml).at(:reach) a.match = (xml).at(:match).inner_html if (xml).at(:match) a.chartposition = (xml).at(:chartposition).inner_html if (xml).at(:chartposition) # in top artists for tag a.count = xml['count'] if xml['count'] a.streamable = xml['streamable'] if xml['streamable'] a.streamable = (xml).at(:streamable).inner_html == '1' ? 'yes' : 'no' if a.streamable.nil? && (xml).at(:streamable) a end |
Instance Method Details
#api_path ⇒ Object
97 98 99 |
# File 'lib/scrobbler/artist.rb', line 97 def api_path "/#{API_VERSION}/artist/#{CGI::escape(name)}" end |
#current_events(format = :ics) ⇒ Object
101 102 103 104 105 |
# File 'lib/scrobbler/artist.rb', line 101 def current_events(format=:ics) format = :ics if format.to_s == 'ical' raise ArgumentError unless ['ics', 'rss'].include?(format.to_s) "#{API_URL.chop}#{api_path}/events.#{format}" end |
#similar(force = false) ⇒ Object
107 108 109 |
# File 'lib/scrobbler/artist.rb', line 107 def similar(force=false) get_instance(:similar, :similar, :artist, force) end |
#top_albums(force = false) ⇒ Object
119 120 121 |
# File 'lib/scrobbler/artist.rb', line 119 def top_albums(force=false) get_instance(:topalbums, :top_albums, :album, force) end |
#top_fans(force = false) ⇒ Object
111 112 113 |
# File 'lib/scrobbler/artist.rb', line 111 def top_fans(force=false) get_instance(:fans, :top_fans, :user, force) end |
#top_tags(force = false) ⇒ Object
123 124 125 |
# File 'lib/scrobbler/artist.rb', line 123 def (force=false) get_instance(:toptags, :top_tags, :tag, force) end |
#top_tracks(force = false) ⇒ Object
115 116 117 |
# File 'lib/scrobbler/artist.rb', line 115 def top_tracks(force=false) get_instance(:toptracks, :top_tracks, :track, force) end |