Alle Thursday 18 September 2008, Nit Khair ha scritto:
Aah, thanks. Yes, I used facets last year...
However, would be grateful if you could tell me how to decide what to
use in the require statement for a facets class. Whenever i use facets,
i struggle to figure out the require statement. What is shown in the
examples often does not work.
Some while back I came upon ProgressBar. It took me a while of trying to
figure out the require.
Then Console::ANSICode gives an example: "include Console::ANSICode"
irb(main):011:0> include Console::ANSICode
NameError: uninitialized constant Console
from (irb):11
I tried many combinations, finally "require 'facets/ansicode'" did not
give an error but still the "include Console::ANSICode" gives the error
above.
I can't remember if I managed to make the example run or not.
(I have started with require rubygems and facets.)
According to the facets documentation, a simple
require 'facets'
will require all the Core facets library. If you want to load only the Core
methods for a single class (for example, the File class), you can do
require 'facets/file'
If you want only to load a specific method, you can find the file where it's
defined by looking up the method you're interested to in the facets rdoc api
(
http://facets.rubyforge.org/doc/index.html), then clicking on the "show
source" link. This will display the source code for the method. At the top of
the source code, there's a comment with the name of the file where the method
is defined. This is the file you need to require. Note, however, that that
line starts with something like 'lib/core/facets/.../'. You should only put
the part of the string starting with facets in your call to require.
All what I said is valid for recent versions of facets, so if you have an old
version, you may need to update it.
Stefano
Stefano