Class: Faces::Providers::Flickr
- Inherits:
-
Object
- Object
- Faces::Providers::Flickr
- Defined in:
- lib/providers/flickr.rb
Overview
Flickr class handles all Flickr based avatar methods, check the information page for more details: nickpellant.com/open-source/faces/ruby/providers/flickr
Default required methods for providers are url
and/or html
, exists?
All other methods are at the discretion of the developer Check the provider creation guide for more details: nickpellant.com/open-source/faces/ruby/developing-providers
Instance Method Summary collapse
-
#exists?(user_id, configuration = {}) ⇒ Boolean
Checks Avatar exists.
-
#html(user_id, configuration = {}) ⇒ Object
Constructs HTML <img /> tag for Flickr.
-
#ssl? ⇒ Boolean
Doesn’t support SSL.
-
#url(user_id, configuration = {}) ⇒ Object
Constructs Flickr url from user_id/configuration.
Instance Method Details
#exists?(user_id, configuration = {}) ⇒ Boolean
Checks Avatar exists
31 32 33 34 35 36 37 38 |
# File 'lib/providers/flickr.rb', line 31 def exists?(user_id, configuration = {}) url = URI.parse(url(user_id, configuration)) http = Net::HTTP.new(url.host, url.port) http.use_ssl = (url.scheme == 'https') request = Net::HTTP::Get.new(url.path) response = http.request(request) response.code == '200' ? true : false end |
#html(user_id, configuration = {}) ⇒ Object
Constructs HTML <img /> tag for Flickr
26 27 28 29 |
# File 'lib/providers/flickr.rb', line 26 def html(user_id, configuration = {}) m_configuration = Faces::Common.merge_configurations([Faces::Configuration::FLICKR, configuration]) Faces::Public.generate_html(url(user_id, configuration), m_configuration) end |
#ssl? ⇒ Boolean
Doesn’t support SSL
40 |
# File 'lib/providers/flickr.rb', line 40 def ssl?; false; end |
#url(user_id, configuration = {}) ⇒ Object
Constructs Flickr url from user_id/configuration
21 22 23 24 |
# File 'lib/providers/flickr.rb', line 21 def url(user_id, configuration = {}) m_configuration = Faces::Common.merge_configurations([Faces::Configuration::FLICKR, configuration]) hostname(flickr_avatar_details(user_id, m_configuration)) + user_id + '.jpg' end |