Module: Ramaze::CoreExtensions::Object
- Defined in:
- lib/ramaze/snippets/object/__dir__.rb
Overview
Extensions for Object
Instance Method Summary collapse
-
#__DIR__(*args) ⇒ Object
This is similar to
__FILE__
and__LINE__
, and returns a String representing the directory of the current file is.
Instance Method Details
#__DIR__(*args) ⇒ Object
This is similar to __FILE__
and __LINE__
, and returns a String representing the directory of the current file is. Unlike __FILE__
the path returned is absolute.
This method is convenience for the
File.(File.dirname(__FILE__))
idiom.
17 18 19 20 21 |
# File 'lib/ramaze/snippets/object/__dir__.rb', line 17 def __DIR__(*args) filename = caller[0][/^(.*):/, 1] dir = File.(File.dirname(filename)) ::File.(::File.join(dir, *args.map{|a| a.to_s})) end |