Class: Pathname

Inherits:
Object
  • Object
show all
Defined in:
lib/relative/pathname.rb

Instance Method Summary collapse

Instance Method Details

#expand_path_relative_to_callerObject

Description:

This method returns an absolute expansion of self, relative to the caller’s source file. Note that this method is a no-op if self is an absolute Pathname.

Examples:

If the caller’s source file is:

/usr/bin/scripts/print_file.rb

then

relative_path = Pathname.new("config/print_file.cfg")
absolute_path = relative_path.expand_path_relative_to_caller()

will make absolute_path equal to:

Pathname.new("/usr/bin/scripts/config/print_file.cfg")

Parameters:

file_name

A file system path relative to the calling file

Returns:

An absolute expansion of self, relative to the caller’s source file.



28
29
30
# File 'lib/relative/pathname.rb', line 28

def expand_path_relative_to_caller
  return Pathname.new(File.expand_path_relative_to_caller(to_s()))
end