__PATH__ like __FILE__?

Hello.
I’m rather new to Ruby, so please bare with me. I just want to know if
there is anything similar to FILE but which represents either the
path to the directory which FILE lies in, or the FILE including
the full path to the file?

–Deniz D.

On Mar 2, 2007, at 7:55 AM, Deniz D. wrote:

Hello.

Hello.

I’m rather new to Ruby, so please bare with me.

Welcome to Ruby then.

I just want to know if there is anything similar to FILE but
which represents either the path to the directory which FILE
lies in, or the FILE including the full path to the file?

Just ask Ruby to expand it for you:

File.expand_path(FILE)

Hope that helps.

James Edward G. II

Le vendredi 02 mars 2007 14:55, Deniz D. a écrit :

Hello.
I’m rather new to Ruby, so please bare with me. I just want to know if
there is anything similar to FILE but which represents either the
path to the directory which FILE lies in, or the FILE including
the full path to the file?

–Deniz D.

You have to use the File.expand_path to do this :

File.expand_path(FILE)
File.dirname(File.expand_path(FILE))

On 3/2/07, Deniz D. [email protected] wrote:

Hello.
I’m rather new to Ruby, so please bare with me. I just want to know if
there is anything similar to FILE but which represents either the
path to the directory which FILE lies in, or the FILE including
the full path to the file?

–Deniz D.

Deniz;

Take a look at the ‘pathname’ library included with ruby:

http://www.ruby-doc.org/stdlib/libdoc/pathname/rdoc/classes/Pathname.html

You should be able to get all that information by combining it with
FILE:

path = Pathname.new(__FILE__)
p path.dirname
p path.expand_path

# ...

Olivier R. wrote:

You have to use the File.expand_path to do this :

File.expand_path(FILE)
File.dirname(File.expand_path(FILE))

Or:
File.expand_path(FILE+’/…’)

:wink:

Daniel

On Mar 2, 8:55 am, Deniz D. [email protected] wrote:

Hello.
I’m rather new to Ruby, so please bare with me. I just want to know if
there is anything similar to FILE but which represents either the
path to the directory which FILE lies in, or the FILE including
the full path to the file?

I suggested the same a while back as DIR. I too think it would be
a good thing to have.

T.

Olivier R. wrote:

File.expand_path(FILE)
File.dirname(File.expand_path(FILE))

Thanks to both of you.

On 3/3/07, Daniel DeLorme [email protected] wrote:

Daniel

Or even:

File.expand_path(‘…’, FILE)

Oh, the choices!

George.

On Sat, Mar 03, 2007 at 12:15:31AM +0900, George O. wrote:

:wink:

Daniel

Or even:

File.expand_path(’…’, FILE)

Ooh, that one’s pretty.