Created
September 10, 2008 15:02
-
-
Save maxim/9899 to your computer and use it in GitHub Desktop.
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
class Color | |
def hex | |
[@red, @green, @blue].map do |el| | |
r = el.to_s(16) | |
r = '0' + r if r.size < 2 | |
r | |
end.join | |
end | |
alias_method :to_s, :hex | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment