Skip to content

Instantly share code, notes, and snippets.

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