Created
March 8, 2011 18:32
-
-
Save gmgent/860724 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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