ruby C:\scripts\helloworld.rb

helloworld.rb:
----------------------------------------------
# What can I put here to display the value C:\scripts\ or C:\scripts?
puts $0
puts _FILE_
puts ARGV[0]
----------------------------------------------

output:
----------------------------------------------
C:/scripts/helloworld.rb
C:/scripts/helloworld.rb:3: undefined local variable or method
`_FILE_' for main:Object (NameError)
----------------------------------------------


ruby C:\scripts\helloworld.rb

helloworld.rb:
----------------------------------------------
# What can I put here to display the value C:\scripts\ or C:\scripts?
puts $0
puts ARGV[0]
----------------------------------------------

output:
----------------------------------------------
C:/scripts/helloworld.rb
onlyarg

----------------------------------------------

I found the $0 documented in the
http://www.rubycentral.com/book/rubyworld.html page.

Justin, how would you recommend me using the _FILE_ constant?

Thanks,

Matthew

On 1/11/07, Justin Bailey <jgbailey / gmail.com> wrote:
> On 1/11/07, Matthew Hailstone <matthew.hailstone / gmail.com> wrote:
> > When I execute a ruby script by the following:
> >
> > ruby <path>helloworld.rb onlyarg
> >
> > How can I find what <path> equals?
>
> The constant __FILE__ will contain the full path to the currently
> executing file.
>
> Justin
>
>