From: Joel VanderWerf Date: 2002-12-20T17:19:46+09:00 Subject: Re: determing defined constants for a class Robert McGovern wrote: > Okay so constants returns an array of the constant names as a string in > short form (i.e. not including the path needed to use them). Hmm, so > with the following sample code, if I want to verify that an method is > passed a valid constant argument what would I want to do? (given the > constant will be passed into the method as a numeric) Have you considered using constants with a symbolic rather than numeric value? TRACK_LENGTH = :TRACK_LENGTH TRACK_TITLE = :TRACK_TITLE Or, if you want to make sure that the only access to these values is through the ID3::V2::Frame scope, you could create some objects: TRACK_LENGTH = Object.new TRACK_TITLE = Object.new In this case, the array Frame.constants.map{|c|Frame.class_eval(c)} will let you check if a given objects is one of your allowed constants. (You might consider a hash for this, if it's going to be large.)