Skip to content

Instantly share code, notes, and snippets.

@benlangfeld
Forked from namtsui/gist:749877
Created December 21, 2010 13:06
Show Gist options
  • Save benlangfeld/749909 to your computer and use it in GitHub Desktop.
Save benlangfeld/749909 to your computer and use it in GitHub Desktop.
def self.get_breaking_news(min)
doc = Hpricot.XML open("http://bensbargains.net/rss.xml/")
cutoff_time = Time.now - 60 * min
(doc/"item").map do |item|
profit_margin = (temp_deal.cost_retail.nil? || temp_deal.cost.nil?) ? nil : temp_deal.cost_retail - temp_deal.cost
Deal.new :name => (item/"title").inner_html, :description => (item/"description").inner_text + (item/"link").inner_html, :guid => (item/"guid").inner_html, :cost => get_price(temp_deal.name), :cost_retail => get_price_retail(temp_deal.description), :profit_margin => profit_margin, :source => "bensbargains"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment