Skip to content

Instantly share code, notes, and snippets.

@mattetti
Created January 4, 2010 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mattetti/96954a4e59f1293977c0 to your computer and use it in GitHub Desktop.
Save mattetti/96954a4e59f1293977c0 to your computer and use it in GitHub Desktop.
framework 'Cocoa'
url_string = 'http://macruby.icoretech.org/latest'
url = NSURL.URLWithString(url_string)
req = NSURLRequest.requestWithURL(url)
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
file_download = NSURLDownload.alloc.initWithRequest(req, delegate: self)
# 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