From: Brian Candler Date: 2009-01-22T06:48:49+09:00 Subject: Re: class doesn't know about calling program's libraries? Tom Cloyd wrote: > Inside the class is this line - > > opt = Readline::readline( ":: " ) > > which generates this error - > uninitialized constant SetLogLevel::Readline (NameError) At a guess: you are running this *before* you have done require 'readline' The easiest solution is to put require 'readline' at the top of this source file. If it has already been required, this will do nothing; but if it has not already been required, it will load it in. > Two questions: > 1. Is my class really so unaware of the calling program's namespace (I > rather think yes). I am not sure what you mean about this. Constants are searched for in your own class, encoding classes/modules, and the top level. You can say ::Readline instead of Readline if you mean "I must use the one defined in the top level", but this will only make a difference if your class has its own Readline as well, in which case a bare 'Readline' will use the one within your class. > 2. If so, what is the best way to make sure the class has access to the > libraries already loaded in the calling program? require 'filename_containing_library' at the top of each source file which makes use of the class(es) defined in that library. -- Posted via http://www.ruby-forum.com/.