Method: Mechanize::Download#save!
- Defined in:
- lib/mechanize/download.rb
permalink #save!(filename = nil) ⇒ Object
Use this method to save the content of body_io to filename
. This method will overwrite any existing filename that exists with the same name. returns the filename
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/mechanize/download.rb', line 70 def save! filename = nil filename ||= @filename dirname = File.dirname filename FileUtils.mkdir_p dirname ::File.open(filename, 'wb')do |io| until @body_io.eof? do io.write @body_io.read 16384 end end filename end |