Just curious, can I write a class that can check values as they are 
assigned to objects?

foo = Klass.new
 foo.legal_values = (4..10)

foo.value = 5  # OK
foo.value = 11 # ERROR - out of bounds, raise exception or something

Also, do I have to have an explicit method for the 'value', or can it 
operate like a "builtin" class, like this :

foo = Klass.new
 foo.legal_values = (4..10)

foo = 5  # OK
foo = 11 # ERROR - out of bounds, raise exception or something

In Perl, I would probably use tiescalar for something like this, where I 
can intercept an assignment...

Also, it may not be numbers, but enums as well.

Thanks.

-- 
Posted via http://www.ruby-forum.com/.