Sha256: bc41958c59f74984e72c3a1c6499d7207f7764e78521ec01f09e2f4ace5d42b0

Contents?: true

Size: 796 Bytes

Versions: 7

Compression:

Stored size: 796 Bytes

Contents

##
# This is a pluggable parser that automatically saves every file it
# encounters.  It saves the files 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

class Mechanize::FileSaver < Mechanize::Download

  attr_reader :filename

  def initialize uri = nil, response = nil, body_io = nil, code = nil
    @full_path = true

    super

    save @filename
  end

  ##
  # The save_as alias is provided for backwards compatibility with mechanize
  # 2.0.  It will be removed in mechanize 3.
  #--
  # TODO remove in mechanize 3

  alias save_as save

end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
mechanize-2.1.1 lib/mechanize/file_saver.rb
domo-0.0.5 vendor/bundle/ruby/1.9.1/gems/mechanize-2.1/lib/mechanize/file_saver.rb
diamond-mechanize-2.4 lib/mechanize/file_saver.rb
diamond-mechanize-2.3 lib/mechanize/file_saver.rb
diamond-mechanize-2.1 lib/mechanize/file_saver.rb
mechanize-2.1 lib/mechanize/file_saver.rb
mechanize-2.1.pre.1 lib/mechanize/file_saver.rb