Skip to content

Instantly share code, notes, and snippets.

@maxim
Created September 10, 2008 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxim/9899 to your computer and use it in GitHub Desktop.
Save maxim/9899 to your computer and use it in GitHub Desktop.
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