Class: SnipSnap::Flickr

Inherits:
Object
  • Object
show all
Includes:
Client
Defined in:
lib/snip_snap/flickr.rb

Instance Method Summary collapse

Methods included from Client

included

Instance Method Details

#endpoint_urlObject



8
9
10
# File 'lib/snip_snap/flickr.rb', line 8

def endpoint_url
  response.last_effective_url
end

#identifierObject



12
13
14
15
16
17
# File 'lib/snip_snap/flickr.rb', line 12

def identifier
  pattern = /^http:\/\/(?:www\.)?flickr.com\/photos\/[^\/]+\/(\d+)/
  match = endpoint_url.match(pattern)
  
  match[1] unless match.nil?
end

#image_urlObject



24
25
26
# File 'lib/snip_snap/flickr.rb', line 24

def image_url
  photo.medium.url
end

#photoObject

TODO: Handle case when this fetch fails (e.g. invalid photo ID)



20
21
22
# File 'lib/snip_snap/flickr.rb', line 20

def photo
  Fleakr::Objects::Photo.find_by_id(identifier)
end