Sha256: 6d3f6edafda359913d1b05f46975b8252c0f9f1f7b99cc9c65140bc68baae76d
Contents?: true
Size: 814 Bytes
Versions: 1
Compression:
Stored size: 814 Bytes
Contents
class File RELATIVE_PARENTDIR = '..' # Turns a path +to+ into a relative path from starting # point +from+. The argument +from+ is assumed to be # a filename. To treat it as a directory, make sure it # ends in {File::SEPARATOR} ('/' on UNIX filesystems). # # @param [String] from the starting filename # (or directory with +from_isdir+ set to +true+). # # @param [String] to the final path that should be made relative. # # @return [String] the relative path from +from+ to +to+. # def self.relative_path(from, to) from = expand_path(from).split(SEPARATOR) to = expand_path(to).split(SEPARATOR) from.length.times do break if from[0] != to[0] from.shift; to.shift end fname = from.pop join *(from.map { RELATIVE_PARENTDIR } + to) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yard-0.2.2 | lib/yard/core_ext/file.rb |