Skip to content

Instantly share code, notes, and snippets.

@xpepper
Created April 17, 2013 21:39
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 xpepper/5407997 to your computer and use it in GitHub Desktop.
Save xpepper/5407997 to your computer and use it in GitHub Desktop.
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