Skip to content

Instantly share code, notes, and snippets.

@weatheredwatcher
Created October 14, 2010 04:23
Show Gist options
  • Save weatheredwatcher/625572 to your computer and use it in GitHub Desktop.
Save weatheredwatcher/625572 to your computer and use it in GitHub Desktop.
class GetLastFmFeed
def self.displayFeed
require 'rss'
require 'open-uri'
@lastfmArray = []
rss = RSS::Parser.parse open('http://ws.audioscrobbler.com/1.0/user/minasmir/recenttracks.rss').read, false
puts rss.channel.title
@lastfmArray.push "<p class='section'>Last.FM Feed</p>"
@lastfmArray.push "<ul style='font-size:11px;'>"
rss.items.each_with_index do |item,i|
puts "" if i.zero? or item.date.day != rss.items[i-1].date.day
line = "<li><a href=\"#{item.link}\">#{item.title}</a></li> "
@lastfmArray.push line
end
@lastfmArray.push "</ul>"
return @lastfmArray
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment