class Consummo::FeedFetcher
Public Class Methods
new(client: FeedClient.new, factory: FeedItemFactory.new)
click to toggle source
# File lib/consummo/feed_fetcher.rb, line 3 def initialize(client: FeedClient.new, factory: FeedItemFactory.new) @client = client @factory = factory end
Public Instance Methods
fetch(feed, last_modified = nil)
click to toggle source
# File lib/consummo/feed_fetcher.rb, line 8 def fetch(feed, last_modified = nil) @client.fetch_and_parse(feed.uri).map do |entry| next if old_entry?(entry, last_modified) item = @factory.build(entry) item.attributes = {:feed_id => feed.id} item end.compact end
Private Instance Methods
old_entry?(entry, last_modified)
click to toggle source
# File lib/consummo/feed_fetcher.rb, line 19 def old_entry?(entry, last_modified) return false if last_modified.nil? last_modified > entry.last_modified end