Method: String#relative_path_from

Defined in:
lib/extlib/string.rb

#relative_path_from(other) ⇒ String

Calculate a relative path from other.

"/opt/local/lib".relative_path_from("/opt/local/lib/ruby/site_ruby") # => "../.."

Parameters:

  • other (String)

    Base path to calculate from.

Returns:

  • (String)

    Relative path from other to receiver.



107
108
109
# File 'lib/extlib/string.rb', line 107

def relative_path_from(other)
  Pathname.new(self).relative_path_from(Pathname.new(other)).to_s
end