Module: Terror::FeedFetcher::ClassMethods

Defined in:
lib/terror/feed_fetcher.rb

Instance Method Summary collapse

Instance Method Details

#create_from_entry(feed, entry) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/terror/feed_fetcher.rb', line 18

def create_from_entry(feed, entry)
  self.create(
    :title => entry.title, 
    :url => entry.url, 
    :source => feed.title, 
    :date => entry.date_published
  )  unless self.first(:url => entry.url)
end

#fetch_all(url) ⇒ Object



13
14
15
16
# File 'lib/terror/feed_fetcher.rb', line 13

def fetch_all(url)
  feed = FeedNormalizer::FeedNormalizer.parse(open(url))
  feed.entries.each{|entry| create_from_entry(feed, entry)}
end