class Yadisk::Main
Constants
- BASE_URL
Public Instance Methods
download(url, folder: ".
click to toggle source
# File lib/yadisk.rb, line 15 def download(url, folder: ".#{File::SEPARATOR}", wget_options: nil) enc_url = CGI::escape(url) response = Net::HTTP.get(URI("#{BASE_URL}#{enc_url}")) json_res = JSON.parse(response) download_url = json_res['href'] filename = CGI::parse(URI(download_url).query)["filename"][0] folder = folder + File::SEPARATOR if not folder.end_with?(File::SEPARATOR) download_path = folder + filename wget_options = (wget_options || "") + "--no-check-certificate" if Yadisk::OS.windows? system("wget #{esc(download_url)} -O #{esc(download_path)} #{wget_options}") end
Private Instance Methods
esc(str)
click to toggle source
# File lib/yadisk.rb, line 29 def esc(str) "#{escape_symbol}#{str}#{escape_symbol}" end
escape_symbol()
click to toggle source
# File lib/yadisk.rb, line 33 def escape_symbol Yadisk::OS.windows? ? '"' : "'" end