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, this method will try to find a free filename by appending numbers to the default filename. Returns the full path of the saved file.
17 18 19 20 21 22 23 24 |
# File 'lib/grubby/mechanize/parser.rb', line 17 def save_to(directory) raise "#{self.class}#save! is not defined" unless self.respond_to?(:save!) FileUtils.mkdir_p(directory) path = find_free_name(File.join(directory, @filename)) save!(path) path end |