Last active
August 29, 2015 13:57
-
-
Save clamstew/9349185 to your computer and use it in GitHub Desktop.
email gravatar each loop. outputs a hash of all the emails input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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