Methods

Mechanize::FileSaver

This is a pluggable parser that automatically saves every file it encounters. Unlike Mechanize::DirectorySaver, the file saver saves the responses as a tree, reflecting the host and file path.

Example

This example saves all .pdf files

  require 'mechanize'

  agent = Mechanize.new
  agent.pluggable_parser.pdf = Mechanize::FileSaver
  agent.get 'http://example.com/foo.pdf'

  Dir['example.com/*'] # => foo.pdf

Attributes

filename[R]

Public Class Methods

new(uri = nil, response = nil, body_io = nil, code = nil) click to toggle source
    # File lib/mechanize/file_saver.rb, line 22
22:   def initialize uri = nil, response = nil, body_io = nil, code = nil
23:     @full_path = true
24: 
25:     super
26: 
27:     save @filename
28:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.