Class: Gravatar
- Inherits:
-
Object
- Object
- Gravatar
- Defined in:
- lib/gravatar-api.rb,
lib/gravatar-api/url.rb,
lib/gravatar-api/hash.rb
Class Method Summary collapse
-
.hash!(email) ⇒ Object
MD5 hash an email or string.
Instance Method Summary collapse
-
#hash! ⇒ Object
(also: #hash)
MD5 hash the given email.
-
#initialize(email) ⇒ Gravatar
constructor
A new instance of Gravatar.
-
#url(options = { :size => 80 }) ⇒ Object
(also: #get)
Get your Gravatar URL.
Constructor Details
#initialize(email) ⇒ Gravatar
Returns a new instance of Gravatar.
6 7 8 |
# File 'lib/gravatar-api.rb', line 6 def initialize(email) @@email = email end |
Class Method Details
.hash!(email) ⇒ Object
MD5 hash an email or string.
5 6 7 8 9 |
# File 'lib/gravatar-api/hash.rb', line 5 def self.hash!(email) email.downcase! hash = Digest::MD5.hexdigest(email) return hash end |
Instance Method Details
#hash! ⇒ Object Also known as: hash
MD5 hash the given email.
12 13 14 15 16 |
# File 'lib/gravatar-api/hash.rb', line 12 def hash! @@email.downcase! hash = Digest::MD5.hexdigest(@@email) return hash end |
#url(options = { :size => 80 }) ⇒ Object Also known as: get
Get your Gravatar URL. Also a hash for size.
3 4 5 6 7 8 9 10 |
# File 'lib/gravatar-api/url.rb', line 3 def url( = { :size => 80 }) hash = Gravatar.hash!(@@email) if [:size] == 80 return "http://www.gravatar.com/avatar/#{hash}" else return "http://www.gravatar.com/avatar/#{hash}?s=#{[:size]}" end end |