Class: LastFM::Tag
Instance Attribute Summary collapse
-
#count ⇒ Fixnum
The current value of count.
-
#name ⇒ String
The current value of name.
-
#reach ⇒ Fixnum
The current value of reach.
-
#streamable ⇒ Boolean
The current value of streamable.
-
#url ⇒ String
The current value of url.
-
#wiki ⇒ LastFM::Wiki
The current value of wiki.
Class Method Summary collapse
-
.get_info(params) ⇒ LastFM::Tag
Get the metadata for a tag.
-
.get_similar(params) ⇒ Array<LastFM::Tag>
Search for tags similar to this one.
-
.get_top_albums(params) ⇒ Array[LastFM::Album]
Get the top albums tagged with a tag, ordered by tag count.
-
.get_top_artists(params) ⇒ Array[LastFM::Artist]
Get the top artists tagged with a tag, ordered by tag count.
-
.get_top_tags ⇒ Array<LastFM::Tag>
Fetches the top global tags on Last.fm, sorted by popularity (number of times used).
-
.get_top_tracks(params) ⇒ Array[LastFM::Track]
Get the top tracks tagged with a tag, ordered by tag count.
-
.get_weekly_artist_chart(params) ⇒ Object
Get an artist chart for a tag, for a given date range.
-
.get_weekly_chart_list(params) ⇒ Object
Get a list of available charts for this tag, expressed as date ranges which can be sent to the chart services.
-
.search(params) ⇒ Array<LastFM::Tag>
Search for a tag by name.
Instance Method Summary collapse
Methods inherited from Struct
from_xml, inherited, #initialize, package, #to_json
Constructor Details
This class inherits a constructor from LastFM::Struct
Instance Attribute Details
#count ⇒ Fixnum
Returns the current value of count.
9 10 11 |
# File 'lib/lastfm/tag.rb', line 9 def count @count end |
#name ⇒ String
Returns the current value of name.
9 10 11 |
# File 'lib/lastfm/tag.rb', line 9 def name @name end |
#reach ⇒ Fixnum
Returns the current value of reach.
9 10 11 |
# File 'lib/lastfm/tag.rb', line 9 def reach @reach end |
#streamable ⇒ Boolean
Returns the current value of streamable.
9 10 11 |
# File 'lib/lastfm/tag.rb', line 9 def streamable @streamable end |
#url ⇒ String
Returns the current value of url.
9 10 11 |
# File 'lib/lastfm/tag.rb', line 9 def url @url end |
#wiki ⇒ LastFM::Wiki
Returns the current value of wiki.
9 10 11 |
# File 'lib/lastfm/tag.rb', line 9 def wiki @wiki end |
Class Method Details
.get_info(params) ⇒ LastFM::Tag
Get the metadata for a tag.
37 38 39 40 |
# File 'lib/lastfm/tag.rb', line 37 def get_info( params ) xml = LastFM.get( "tag.getInfo", params ) LastFM::Tag.from_xml( xml ) end |
.get_similar(params) ⇒ Array<LastFM::Tag>
Search for tags similar to this one. Returns tags ranked by similarity, based on listening data.
47 48 49 50 51 52 |
# File 'lib/lastfm/tag.rb', line 47 def get_similar( params ) xml = LastFM.get( "tag.getSimilar", params ) xml.find('similartags/tag').map do |tag| LastFM::Tag.from_xml( tag ) end end |
.get_top_albums(params) ⇒ Array[LastFM::Album]
Get the top albums tagged with a tag, ordered by tag count.
61 62 63 64 65 66 |
# File 'lib/lastfm/tag.rb', line 61 def get_top_albums( params ) xml = LastFM.get( "tag.getTopAlbums", params ) xml.find('topalbums/album').map do |album| LastFM::Album.from_xml( album ) end end |
.get_top_artists(params) ⇒ Array[LastFM::Artist]
Get the top artists tagged with a tag, ordered by tag count.
75 76 77 78 79 80 |
# File 'lib/lastfm/tag.rb', line 75 def get_top_artists( params ) xml = LastFM.get( "tag.getTopArtists", params ) xml.find('topartists/artist').map do |artist| LastFM::Artist.from_xml( artist ) end end |
.get_top_tags ⇒ Array<LastFM::Tag>
Fetches the top global tags on Last.fm, sorted by popularity (number of times used).
86 87 88 89 90 91 |
# File 'lib/lastfm/tag.rb', line 86 def xml = LastFM.get( "tag.getTopTags" ) xml.find('toptags/tag').map do |tag| LastFM::Tag.from_xml( tag ) end end |
.get_top_tracks(params) ⇒ Array[LastFM::Track]
Get the top tracks tagged with a tag, ordered by tag count.
100 101 102 103 104 105 |
# File 'lib/lastfm/tag.rb', line 100 def get_top_tracks( params ) xml = LastFM.get( "tag.getTopTracks", params ) xml.find('toptracks/track').map do |track| LastFM::Track.from_xml( track ) end end |
.get_weekly_artist_chart(params) ⇒ Object
Get an artist chart for a tag, for a given date range. If no date range is supplied, it will return the most recent artist chart for this tag.
115 116 117 |
# File 'lib/lastfm/tag.rb', line 115 def get_weekly_artist_chart( params ) LastFM.get( "tag.getWeeklyArtistChart", params ) end |
.get_weekly_chart_list(params) ⇒ Object
Get a list of available charts for this tag, expressed as date ranges which can be sent to the chart services.
124 125 126 |
# File 'lib/lastfm/tag.rb', line 124 def get_weekly_chart_list( params ) LastFM.get( "tag.getWeeklyChartList", params ) end |
.search(params) ⇒ Array<LastFM::Tag>
Search for a tag by name. Returns matches sorted by relevance.
135 136 137 138 139 140 |
# File 'lib/lastfm/tag.rb', line 135 def search( params ) xml = LastFM.get( "tag.search", params ) xml.find('results/tagmatches/tag').map do |tag| LastFM::Tag.from_xml( tag ) end end |
Instance Method Details
#update_from_node(node) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/lastfm/tag.rb', line 11 def update_from_node(node) case node.name.to_sym when :name self.name = node.content when :url self.url = node.content when :reach self.reach = node.content.to_i when :count, :taggings self.count = node.content.to_i when :streamable self.streamable = (node.content == '1') when :wiki self.wiki = LastFM::Wiki.from_xml(node) end end |