Skip to content
instance method

Pathname#relative_path_from

(::Pathname | ::string base_directory) -> ::Pathname
relative_path_from(base_directory)

Returns a relative path from the given base_directory to the receiver.

If self is absolute, then base_directory must be absolute too.

If self is relative, then base_directory must be relative too.

This method doesn’t access the filesystem. It assumes no symlinks.

ArgumentError is raised when it cannot find a relative path.

Note that this method does not handle situations where the case sensitivity of the filesystem in use differs from the operating system default.

See also #relative? #rename #realpath #rmdir also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0