Module: Kernel

Defined in:
lib/relative/kernel.rb

Instance Method Summary collapse

Instance Method Details

#require_relative(file_name) ⇒ Object

Description:

This method loads the Ruby code contained in file_name, where file_name is expanded relative to the calling source file. Basically, this method is exactly the same as the require method except that it interprets its argument relative to the calling source file rather than to the interpreter’s current working directory. An equivalent require_relative method will be provided as part of the core Ruby 1.9 distribution (see blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/16356; if a require_relative already is defined, this method will not override the existing implementation).

Parameters:

file_name

The file system path of the Ruby source file to load



26
27
28
# File 'lib/relative/kernel.rb', line 26

def require_relative(file_name)
  require(File.expand_path_relative_to_caller(file_name))
end