Class: Mechanize::FileConnection

Inherits:
Object
  • Object
show all
Defined in:
lib/mechanize/file_connection.rb

Overview

Wrapper to make a file URI work like an http URI

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(*a) ⇒ Object



9
10
11
# File 'lib/mechanize/file_connection.rb', line 9

def self.new *a
  @instance ||= super
end

Instance Method Details

#request(uri, request) {|Mechanize::FileResponse.new(Mechanize::Util.uri_unescape(file_path))| ... } ⇒ Object

Yields:



13
14
15
16
17
18
# File 'lib/mechanize/file_connection.rb', line 13

def request uri, request
  file_path = uri.select(:host, :path)
                .select { |part| part && (part.length > 0) }
                .join(":")
  yield Mechanize::FileResponse.new(Mechanize::Util.uri_unescape(file_path))
end