Skip to content

Instantly share code, notes, and snippets.

@athaeryn

athaeryn/hex.rb

Created May 29, 2014
Embed
What would you like to do?
Ruby String -> hex color
require "digest/sha2"
class String
def to_hex_color
"\##{(::Digest::SHA2.new << self).to_s[0...6]}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment