Method: Kernel#require_relative
- Defined in:
- load.c
#require_relative(string) ⇒ Boolean
Ruby tries to load the library named string relative to the requiring file’s path. If the file’s path cannot be determined a LoadError is raised. If a file is loaded true
is returned and false otherwise.
849 850 851 852 853 854 855 856 857 858 |
# File 'load.c', line 849
VALUE
rb_f_require_relative(VALUE obj, VALUE fname)
{
VALUE base = rb_current_realfilepath();
if (NIL_P(base)) {
rb_loaderror("cannot infer basepath");
}
base = rb_file_dirname(base);
return rb_require_string(rb_file_absolute_path(fname, base));
}
|