Created
November 11, 2009 21:31
-
-
Save bernsno/232322 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ShopifyCollection | |
require 'feedzirra' | |
require 'hpricot' | |
BASE_URI = "http://shop.thepostfamily.com/collections/" | |
def initialize(url) | |
@feed = Feedzirra::Feed.fetch_and_parse(BASE_URI + url + ".atom") | |
@entries = @feed.entries | |
end | |
def links_and_images(limit=5) | |
@entries[0..limit.to_i].map do |entry| | |
link = entry.links[1] | |
image = Hpricot.parse(entry.inspect).search('//img[@src]').map { |image| image['src'].gsub(/[\\"]/, '') }[0] | |
collection = [image,link] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment