From: "E. Saynatkari" Date: 2006-03-04T04:02:35+09:00 Subject: Re: require just in a context? cap wrote: > Can I make some libraray just work in a context ? > > I add a new ruby file into my app using "require 'mathn'" but i don't > want every ruby file to use the 'mathn', how can I do it? Well, anytime you call #require, the effect will be global. You can delay the call until a certain point in your program (possibly useful if there is a possibility that it would not be loaded at all) since #require is just a method. For example, def foobar(x, y) require 'mathn' # ... end Would be fine (but would still have an effect just like if you did it at the top of the file). As an alternative, you could wrap the loaded file into a module either using #load which can use an anonymous module (see the docs) or a library such as Script (see RAA) which uses a named module. This approach might not work with mathn or anything else that modifies existing classes. E -- Posted via http://www.ruby-forum.com/.