Hi guys,
My question is the following:
I have a small Ruby code with different classes in a few files. In one of these file, I instantiate an object of the main
class to start the execution.
So this file as to require
my other classes.
(subquestion: is it a good way to start a ruby code ?)
But I have a problem when I run the code from an alias: let's say my main
code is in DIR1/MyRubyCode.rb
and I want to run the code from DIR2/MyRubyCode
which is an alias (ln -s
) to the .rb file.
Then my requires will fail.
I solved inelegantly the problem by adding the path DIR1
to $LOAD_PATH
before the require
. But I think there would be much better ways to do it.
Do you have any suggestions about that ?
Thanks !