Skip to content

Instantly share code, notes, and snippets.

@gmgent
Created March 8, 2011 18:32
Show Gist options
  • Save gmgent/860724 to your computer and use it in GitHub Desktop.
Save gmgent/860724 to your computer and use it in GitHub Desktop.
class Blog
require 'open-uri'
require 'rss'
def self.latest
@blog ||= load_blog
end
protected
def self.load_blog
url = "your_blog.com/rss.xml"
# Variable for storing feed content
rss_content = ""
# Read the feed into rss_content
open(url) do |f|
rss_content = f.read
end
# Parse the feed, dumping its contents to rss
@blog = RSS::Parser.parse(rss_content, false).items.first.description
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment