Class: SocialAvatarProxy::TwitterAvatar

Inherits:
Avatar
  • Object
show all
Defined in:
lib/social_avatar_proxy/twitter_avatar.rb

Instance Attribute Summary

Attributes inherited from Avatar

#identifier

Instance Method Summary collapse

Methods inherited from Avatar

#body, #content_type, #exist?, #file, #initialize, #last_modified

Constructor Details

This class inherits a constructor from SocialAvatarProxy::Avatar

Instance Method Details

#remote_urlObject



5
6
7
8
9
10
11
12
13
# File 'lib/social_avatar_proxy/twitter_avatar.rb', line 5

def remote_url
  if identifier =~ /^\d+$/
    "http://api.twitter.com/1/users/profile_image?user_id=#{identifier}&size=bigger"
  elsif identifier =~ /^[\w\-\.]+$/i
    "http://api.twitter.com/1/users/profile_image?screen_name=#{identifier}&size=bigger"
  else
    raise RuntimeError, "Identifier contains invalid characters"
  end
end