arentweallhorses arentweallhorses - 3 months ago 7
Ruby Question

Save WWW::Mechanize::File to disk using FileUtils

Using Mechanize with Ruby I get a certain file using

, with FileUtils or otherwise, how do I save this file to my hard drive (for instance, in a directory wherefrom the script is running)?

P.S.
class => WWW::Mechanize::File

Answer

Well, WWW::Mechanize::File has a save_as instance method, so I suppose something like this might work:

agent.get('http://example.com/foo.torrent').save_as 'a_file_name'