| Class | Scrobbler::Tag |
| In: |
lib/scrobbler/tag.rb
|
| Parent: | Base |
| count | [RW] | |
| name | [RW] | |
| url | [RW] |
# File lib/scrobbler/tag.rb, line 83
83: def initialize(name)
84: raise ArgumentError, "Name is required" if name.blank?
85: @name = name
86: end
# File lib/scrobbler/tag.rb, line 63
63: def new_from_xml(xml, doc=nil)
64: name = (xml).at(:name).inner_html
65: t = Tag.new(name)
66: t.count = (xml).at(:count).inner_html
67: t.url = (xml).at(:url).inner_html
68: t
69: end
# File lib/scrobbler/tag.rb, line 71
71: def top_tags
72: doc = fetch_and_parse("/#{API_VERSION}/tag/toptags.xml")
73: @top_tags = (doc/:tag).inject([]) do |tags, tag|
74: t = Tag.new(tag['name'])
75: t.count = tag['count']
76: t.url = tag['url']
77: tags << t
78: tags
79: end
80: end
# File lib/scrobbler/tag.rb, line 88
88: def api_path
89: "/#{API_VERSION}/tag/#{CGI::escape(name)}"
90: end
# File lib/scrobbler/tag.rb, line 96
96: def top_albums(force=false)
97: get_instance(:topalbums, :top_albums, :album, force)
98: end
# File lib/scrobbler/tag.rb, line 92
92: def top_artists(force=false)
93: get_instance(:topartists, :top_artists, :artist, force)
94: end