Module: CourseraDownloader::Util
- Defined in:
- lib/coursera_downloader/util.rb
Class Method Summary collapse
Class Method Details
.escape_path(path) ⇒ Object
17 18 19 |
# File 'lib/coursera_downloader/util.rb', line 17 def self.escape_path(path) path.split("/").map{|e| CGI.escape(e)}.join("/") end |
.path_relative_to_path(target_path, path) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/coursera_downloader/util.rb', line 5 def self.path_relative_to_path(target_path, path) target_dirs = target_path.split("/") dirs = path.split("/") while target_dirs.length > 1 && target_dirs[0] == dirs[0] target_dirs.shift dirs.shift end File.join(Array.new(target_dirs.length - 1, "..") + dirs) end |