Class: PosterousFeedImporter
- Inherits:
-
Object
- Object
- PosterousFeedImporter
- Includes:
- IoTools::Helpers::RssFeed, IoTools::Importer
- Defined in:
- lib/server/importers/posterous_feed_importer.rb
Constant Summary collapse
- MAX_PAGES =
2
- FEED_SELECTOR =
'link[type="application/rss+xml"]'
Instance Method Summary collapse
- #feed_url ⇒ Object
- #items_from_page(num) ⇒ Object
- #paginated_feed_items ⇒ Object
- #url_for_page(num) ⇒ Object
Methods included from IoTools::Helpers::RssFeed
Methods included from IoTools::Importer
Instance Method Details
#feed_url ⇒ Object
26 27 28 |
# File 'lib/server/importers/posterous_feed_importer.rb', line 26 def feed_url @feed_url ||= Nokogiri::HTML(open(params[:feed_url])).css(FEED_SELECTOR).first['href'] end |
#items_from_page(num) ⇒ Object
35 36 37 |
# File 'lib/server/importers/posterous_feed_importer.rb', line 35 def items_from_page num feed_items_from(url_for_page(num)) end |
#paginated_feed_items ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/server/importers/posterous_feed_importer.rb', line 18 def paginated_feed_items items = [] 1.upto(MAX_PAGES) do |num| items += items_from_page(num) end items end |
#url_for_page(num) ⇒ Object
30 31 32 33 |
# File 'lib/server/importers/posterous_feed_importer.rb', line 30 def url_for_page num puts "#{feed_url}?page=#{num}" "#{feed_url}?page=#{num}" end |