Module: FlickrPhoto
- Defined in:
- lib/objectiveflickr/flickr_photo.rb
Overview
This helper module provides a set of utility methods for Flickr photos. Methods such as unique_id_from_hash and url_from_unique_id are helpful when you try to move the photo id data to and fro your web apps.
Class Method Summary collapse
-
.default_photo_url_base(b) ⇒ Object
Set the default photo base URL, without the http:// part.
-
.hash_from_unique_id(uid) ⇒ Object
This utility method breaks apart the photo id into Flickr photo keys and returns a hash of the photo information.
-
.unique_id_from_hash(params, prefix = 'photo') ⇒ Object
This utility method combines the Flickr photo keys (from which one gets the real URL of a photo) into a photo id that you can use in a div.
-
.url_from_hash(params) ⇒ Object
This utility method returns the URL of a Flickr photo using the keys :farm, :server, :id, :secret, :size and :type.
-
.url_from_unique_id(uid) ⇒ Object
This utility method breaks apart the photo id into Flickr photo keys and returns the photo URL.
Class Method Details
.default_photo_url_base(b) ⇒ Object
Set the default photo base URL, without the http:// part
19 20 21 |
# File 'lib/objectiveflickr/flickr_photo.rb', line 19 def self.default_photo_url_base(b) @photo_url_base = b end |
.hash_from_unique_id(uid) ⇒ Object
This utility method breaks apart the photo id into Flickr photo keys and returns a hash of the photo information
NOTE: No sanitation check here
47 48 49 50 51 52 53 |
# File 'lib/objectiveflickr/flickr_photo.rb', line 47 def self.hash_from_unique_id(uid) p = uid.split("-") { :server=>p[1], :id=>p[2], :secret=>p[3], :farm=>p[4], :size=>p[5], :type=>p[6] } end |
.unique_id_from_hash(params, prefix = 'photo') ⇒ Object
This utility method combines the Flickr photo keys (from which one gets the real URL of a photo) into a photo id that you can use in a div
32 33 34 35 |
# File 'lib/objectiveflickr/flickr_photo.rb', line 32 def self.unique_id_from_hash(params, prefix='photo') p = self.normalize_parameter(params) [prefix, p[:server], p[:id], p[:secret], p[:farm], p[:size], p[:type]].join("-") end |
.url_from_hash(params) ⇒ Object
This utility method returns the URL of a Flickr photo using the keys :farm, :server, :id, :secret, :size and :type
25 26 27 |
# File 'lib/objectiveflickr/flickr_photo.rb', line 25 def self.url_from_hash(params) self.url_from_normalized_hash(self.normalize_parameter(params)) end |
.url_from_unique_id(uid) ⇒ Object
This utility method breaks apart the photo id into Flickr photo keys and returns the photo URL
39 40 41 |
# File 'lib/objectiveflickr/flickr_photo.rb', line 39 def self.url_from_unique_id(uid) self.url_from_normalized_hash(self.hash_from_unique_id(uid)) end |