Class: Thumbnailer::Flickr
Instance Attribute Summary
Attributes inherited from Base
#embed_url, #small_thumb_image, #thumb_image
Instance Method Summary collapse
-
#initialize(uri) ⇒ Flickr
constructor
A new instance of Flickr.
Constructor Details
#initialize(uri) ⇒ Flickr
Returns a new instance of Flickr.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/thumbnailer/sites/flickr.rb', line 3 def initialize(uri) if uri.path =~ /\/photos\/.*?\/\d+/ image_id = uri.path.split(/\/photos\/.*?\/(\d+)/)[1] data = open("http://api.flickr.com/services/rest/?method=flickr.photos.getSizes&api_key=#{FLICKR_KEY}&photo_id=#{image_id}") doc = XML::Parser.string(data.read).parse.find("//rsp/sizes/size") doc.each { |item| case item['label'] when 'Thumbnail' @thumb_image = item['source'] when 'Square' @small_thumb_image = item['source'] when 'Medium' = item['source'] end } end end |