Class: EmailToFace::Gravatar
- Inherits:
-
Object
- Object
- EmailToFace::Gravatar
- Defined in:
- lib/email_to_face.rb
Class Method Summary collapse
Class Method Details
.user_image(email, fb_type = nil) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/email_to_face.rb', line 42 def self.user_image(email, fb_type=nil) fb_types = { 'square' => 50, 'small' => 50, 'normal' => 100, 'large' => 180 } begin url = "http://www.gravatar.com/avatar.php?gravatar_id=#{Digest::MD5::hexdigest(email)}&d=404&s=#{fb_types[fb_type] || 180}" response = Net::HTTP.get_response(URI.parse(url)) response.code == '200' ? url : nil rescue Exception => e puts e.inspect return nil end end |