Class: Rss
- Inherits:
-
Object
- Object
- Rss
- Defined in:
- lib/rss_gem.rb
Class Method Summary collapse
Class Method Details
.runcheck(feed_link) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rss_gem.rb', line 2 def self.runcheck(feed_link) #Imports require "rss" require "open-uri" #Establish array for news list rss_list = [] #Gets the RSS link passed in through the controller via the "feed_link" and parses the RSS data rss = RSS::Parser.parse(open(feed_link).read, false).items #For each item in the RSS data it saves the title, page link, publish data of that item into an object, it gets the source name from the controller via the "source_name" #Each object is then added the the rss_list array of objects. #Once it has gones through each item in the feed, it will return the array rss.each do |item| item = {title: item.title, link: item.link, pubdate: item.pubDate} rss_list.push(item) end return rss_list end |