Class Mechanize::File
In: lib/mechanize/file.rb
Parent: Object

This is the base class for the Pluggable Parsers. If Mechanize cannot find an appropriate class to use for the content type, this class will be used. For example, if you download an image/jpeg, Mechanize will not know how to parse it, so this class will be instantiated.

This is a good class to use as the base class for building your own pluggable parsers.

Example

  require 'mechanize'

  agent = Mechanize.new
  agent.get('http://example.com/foo.jpg').class  #=> Mechanize::File

Methods

new   save   save_as  

Included Modules

Mechanize::Parser

External Aliases

body -> content

Attributes

body  [RW]  The HTTP response body, the raw file contents
filename  [RW]  The filename for this file based on the content-disposition of the response or the basename of the URL

Public Class methods

Creates a new file retrieved from the given uri and response object. The body is the HTTP response body and code is the HTTP status.

Public Instance methods

Use this method to save the content of this object to filename

save_as(filename = nil)

Alias for save

[Validate]