Module: RssWatcher

Defined in:
lib/rss_watcher.rb,
lib/rss_watcher/version.rb,
lib/rss_watcher/feed_manager.rb

Defined Under Namespace

Classes: Error, FeedManager

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.watch(url:, update_interval: 10, cache_file: "rss_watcher.cache") ⇒ Object

Your code goes here…



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rss_watcher.rb', line 9

def self.watch url:, update_interval: 10, cache_file: "rss_watcher.cache"
  #url - RSS feed url
  #updated_interval - Seconds to wait for between checking for updates to the RSS feed
  #cache_file - Path to a file that this gem uses internally for remembering the last seen item
  while true
    open(url) do |rss|
      feed = RSS::Parser.parse(rss)
      RssWatcher::FeedManager.new(cache_file).get_new_feed_items(feed.items).each do |item|
        yield item if block_given?
      end
    end
    sleep update_interval
  end
end