Sha256: 36472ba25ef7b517ef0b1e798cf6dc3e3f669493344e5c3f5c80cb8c3a218fca

Contents?: true

Size: 661 Bytes

Versions: 6

Compression:

Stored size: 661 Bytes

Contents

require 'digest/md5'

# @author Zamith
# This module provides helper methods to be include in a class which has an email
# such as User
module Gravatar

  # Generates the gravatar id from the object's email
  # @return [String] gravatar id
  def gravatar_id
    Digest::MD5.hexdigest(self.email.to_s.downcase)
  end
  
  # Generates the full gravatar url for the user (always uses https)
  # @param [Hash] options The only available option is the avatar rating you which to fetch
  # @return [String] gravatar url
  def gravatar_url(options = { rating: 'g'})
    "https://secure.gravatar.com/avatar/#{self.gravatar_id}.png/rating=#{options[:rating]}"
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
citygate-0.1.0 lib/gravatar.rb
citygate-0.0.9 lib/gravatar.rb
citygate-0.0.8 lib/gravatar.rb
citygate-0.0.7 lib/gravatar.rb
citygate-0.0.6 lib/gravatar.rb
citygate-0.0.5 lib/gravatar.rb