On Sat, 3 Mar 2007, Timothy Hunter wrote:

> Okay, it's easy to download a file from an FTP server with Net::FTP. Given a 
> URL like this: 
> "http://rubyforge.org/frs/download.php/17670/RMagick-1.15.3.tar.gz" is there 
> a way using pure Ruby to download this file?
>

harp:~ > cat a.rb
require 'open-uri'
uri = 'http://rubyforge.org/frs/download.php/17670/RMagick-1.15.3.tar.gz'

open(uri) do |fin|
   open(File.basename(uri), 'w') do |fout|
     while(buf = fin.read(8192))
       fout.write buf
     end
   end
end

harp:~ > ruby a.rb

harp:~ > new RMagick-1.15.3.tar.gz
-rw-rw-r--    1 ahoward  ahoward   1048764 Mar  3 08:00 RMagick-1.15.3.tar.gz


-a
-- 
be kind whenever possible... it is always possible.
- the dalai lama