Skip to content

Instantly share code, notes, and snippets.

@mrcwinn
Created May 6, 2013 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrcwinn/5526667 to your computer and use it in GitHub Desktop.
Save mrcwinn/5526667 to your computer and use it in GitHub Desktop.
RSS parser
module RssHelper
def rss_links
body = HTTParty.get('http://blog.slimsurveys.com/feeds/posts/default?alt=rss')
items = []
begin
Nokogiri::XML(body).xpath('//item').slice(0, 5).each do |item|
items << content_tag(:a, item.xpath('title').inner_text, href: item.xpath('link').inner_text.to_s )
end
items.collect {|item| content_tag(:li, item)}.join().html_safe
rescue
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment