[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Get file path of script being executed

Ubaldo Villaseca

11/13/2007 5:05:00 PM

Hi all,
I have some directories in my project like:
+ communications
+ model
+ database
+ database/sqlite
+ http

Every directory contains scripts, more specifically classes, that are
called from a main script Portal.rb located in the base directory. How
could those scripts get in its own code its complete path? I try some
solutions from Internet but I just get the path to Portal.rb

Thanks,
Ubaldo

3 Answers

Xavier Noria

11/13/2007 5:10:00 PM

0

On Nov 13, 2007, at 6:04 PM, Ubaldo Villaseca wrote:

> Hi all,
> I have some directories in my project like:
> + communications
> + model
> + database
> + database/sqlite
> + http
>
> Every directory contains scripts, more specifically classes, that are
> called from a main script Portal.rb located in the base directory. How
> could those scripts get in its own code its complete path? I try some
> solutions from Internet but I just get the path to Portal.rb

Check the __FILE__ variable in each one.

-- fxn


Ubaldo Villaseca

11/13/2007 8:48:00 PM

0

On Nov 13, 2007 1:09 PM, Xavier Noria <fxn@hashref.com> wrote:
>
> On Nov 13, 2007, at 6:04 PM, Ubaldo Villaseca wrote:
>
> > Hi all,
> > I have some directories in my project like:
> > + communications
> > + model
> > + database
> > + database/sqlite
> > + http
> >
> > Every directory contains scripts, more specifically classes, that are
> > called from a main script Portal.rb located in the base directory. How
> > could those scripts get in its own code its complete path? I try some
> > solutions from Internet but I just get the path to Portal.rb
>
> Check the __FILE__ variable in each one.
>
> -- fxn
>
>
>

That works great, thanks.

linkin_t

11/14/2007 6:33:00 PM

0

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

actual_folder = File.basedir(__FILE__.gsub(/\\/, '/')

Or something like this...


2007/11/13, Ubaldo Villaseca <villas82@gmail.com>:
>
> On Nov 13, 2007 1:09 PM, Xavier Noria <fxn@hashref.com> wrote:
> >
> > On Nov 13, 2007, at 6:04 PM, Ubaldo Villaseca wrote:
> >
> > > Hi all,
> > > I have some directories in my project like:
> > > + communications
> > > + model
> > > + database
> > > + database/sqlite
> > > + http
> > >
> > > Every directory contains scripts, more specifically classes, that are
> > > called from a main script Portal.rb located in the base directory. How
> > > could those scripts get in its own code its complete path? I try some
> > > solutions from Internet but I just get the path to Portal.rb
> >
> > Check the __FILE__ variable in each one.
> >
> > -- fxn
> >
> >
> >
>
> That works great, thanks.
>
>