Created
May 29, 2014 16:47
-
-
Save athaeryn/b73fe77f7788819db545 to your computer and use it in GitHub Desktop.
Ruby String -> hex color
This file contains 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/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