Skip to content

Instantly share code, notes, and snippets.

@clamstew
Last active August 29, 2015 13:57
Show Gist options
  • Save clamstew/9349185 to your computer and use it in GitHub Desktop.
Save clamstew/9349185 to your computer and use it in GitHub Desktop.
email gravatar each loop. outputs a hash of all the emails input
require 'digest/md5'
# make an email array for images you want to find
array_emails = ["email1", ...]
# make a new hash to store email:image_url as a key value pair
hash_email_image = {}
def gravatar_for(email, options = { size: 50 })
gravatar_id = Digest::MD5::hexdigest(email.downcase)
size = options[:size]
gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}?s=#{size}"
hash_email_image[email] = gravatar_url
end
array_emails.each do |email|
gravatar_for(email)
end
puts hash_email_image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment