Created
April 17, 2013 21:39
-
-
Save xpepper/5407997 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 self.const_missing(name) | |
const_set(name, new(name.to_s.downcase)) | |
end | |
def initialize(color_name) | |
@color_name = color_name | |
end | |
def to_s | |
@color_name | |
end | |
end | |
puts Color::Red | |
puts Color::Blue | |
puts Color::Red != Color::Blue | |
puts Color::Red == Color::Red |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment