Method: Mechanize::Parser#save_to!
- Defined in:
- lib/grubby/mechanize/parser.rb
#save_to!(directory) ⇒ String
Note:
This method expects a #save!
method to be defined by the class extending Mechanize::Parser
, e.g. Mechanize::File#save! and Mechanize::Download#save!.
Saves the payload to a specified directory, using the default filename suggested by the server. If a file with that name already exists, that file will be overwritten. Returns the full path of the saved file.
37 38 39 40 41 42 43 44 |
# File 'lib/grubby/mechanize/parser.rb', line 37 def save_to!(directory) raise "#{self.class}#save! is not defined" unless self.respond_to?(:save!) FileUtils.mkdir_p(directory) path = File.join(directory, @filename) save!(path) path end |