class Gravatar

Public Class Methods

hash!(email) click to toggle source

MD5 hash an email or string.

# File lib/gravatar-api/hash.rb, line 5
def self.hash!(email)
        email.downcase!
        hash = Digest::MD5.hexdigest(email)
        return hash
end
new(email) click to toggle source
# File lib/gravatar-api.rb, line 6
def initialize(email)
        @@email = email
end

Public Instance Methods

get(options = { :size => 80 })

Make a new method ‘get’ the same as the instance method ‘url’.

Alias for: url
hash()
Alias for: hash!
hash!() click to toggle source

MD5 hash the given email.

# File lib/gravatar-api/hash.rb, line 12
def hash!
        @@email.downcase!
        hash = Digest::MD5.hexdigest(@@email)
        return hash
end
Also aliased as: hash
url(options = { :size => 80 }) click to toggle source

Get your Gravatar URL. Also a hash for size.

# File lib/gravatar-api/url.rb, line 3
def url(options = { :size => 80 })
        hash = Gravatar.hash!(@@email)
        if options[:size] == 80
                return "http://www.gravatar.com/avatar/#{hash}"
        else
                return "http://www.gravatar.com/avatar/#{hash}?s=#{options[:size]}"
        end
end
Also aliased as: get