/gist:d5d8f8a5208fa4a4d94c Secret
Created
January 5, 2010 06:31
-
-
Save chapados/d5d8f8a5208fa4a4d94c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
framework 'Cocoa' | |
url_string = 'http://macruby.icoretech.org/latest' | |
url = NSURL.URLWithString(url_string) | |
req = NSURLRequest.requestWithURL(url) | |
class Test | |
def downloadDidBegin(dl_process) | |
puts "downloading..." | |
end | |
def download(dl_process, decideDestinationWithSuggestedFilename:filename) | |
home = NSHomeDirectory() | |
path = home.stringByAppendingPathComponent('Desktop').stringByAppendingPathComponent(filename) | |
dl_process.setDestination(path, allowOverwrite:true) | |
end | |
def download(dl_process, didFailWithError:error) | |
error_description = error.localizedDescription | |
more_details = error.userInfo[NSErrorFailingURLStringKey] | |
puts "Download failed. #{error_description} - #{more_details}" | |
end | |
def downloadDidFinish(dl_process) | |
puts "Download finished!" | |
exit | |
end | |
end | |
file_download = NSURLDownload.alloc.initWithRequest(req, delegate: Test.new) | |
# keep the run loop running | |
NSRunLoop.currentRunLoop.runUntilDate(NSDate.distantFuture) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment