Method: Kernel#__DIR__
- Defined in:
- lib/core/facets/kernel/__dir__.rb
#__DIR__(*paths) ⇒ Object
Similar to __FILE__, __DIR__ provides the directory path to the current executing script.
DEPRECATED: As of Ruby 2.0, which will have #__dir__ method.
CREDIT: Trans
10 11 12 13 14 15 16 17 |
# File 'lib/core/facets/kernel/__dir__.rb', line 10 def __DIR__(*paths) c = caller.first return nil unless c.rindex(/:\d+(:in `.*')?$/) file = $` # File.dirname(c) return nil if /\A\((.*)\)/ =~ file # eval, etc. #File.expand_path(File.join(File.dirname(file), paths)) File.join(File.dirname(file), paths) end |