how to download files in Ruby

# the ruby way to download files :) — useful if you haven’t got wget on the system…
require ‘open-uri’
writeOut = open(whereItGoes, “wb”)
writeOut.write(open(urlToGet).read)
writeOut.close
puts “downloaded” + urlToGet + “\n”

Of course, this reads in the whole file before writing it (I bet), so be careful.

One thought on “how to download files in Ruby

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>