Sha256: 7b7049c27c9d5ac784341c611892907b3a8d0bbc68da4eb72823bd96fcd5ec7a

Contents?: true

Size: 479 Bytes

Versions: 1

Compression:

Stored size: 479 Bytes

Contents

require "cgi"

module CourseraDownloader
  module Util
    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

    def self.escape_path(path)
      path.split("/").map{|e| CGI.escape(e)}.join("/")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
coursera_downloader-1.0.0 lib/coursera_downloader/util.rb