Parent

Methods

Included Modules

Class Index [+]

Quicksearch

Mechanize::Chain::ResponseBodyParser

Public Class Methods

new(pluggable_parser, watch_for_set) click to toggle source
   # File lib/mechanize/chain/response_body_parser.rb, line 6
6:       def initialize(pluggable_parser, watch_for_set)
7:         @pluggable_parser = pluggable_parser
8:         @watch_for_set = watch_for_set
9:       end

Public Instance Methods

handle(ctx, params) click to toggle source
    # File lib/mechanize/chain/response_body_parser.rb, line 11
11:       def handle(ctx, params)
12:         response = params[:response]
13:         response_body = params[:response_body]
14:         uri = params[:uri]
15: 
16:         content_type = nil
17:         unless response['Content-Type'].nil?
18:           data = response['Content-Type'].match(/^([^;]*)/)
19:           content_type = data[1].downcase.split(',')[0] unless data.nil?
20:         end
21: 
22:         # Find our pluggable parser
23:         params[:page] = @pluggable_parser.parser(content_type).new(
24:                                                                    uri,
25:                                                                    response,
26:                                                                    response_body,
27:                                                                    response.code
28:                                                                    ) { |parser|
29:           parser.mech = params[:agent] if parser.respond_to? :mech=
30:           if parser.respond_to?(:watch_for_set=) && @watch_for_set
31:             parser.watch_for_set = @watch_for_set
32:           end
33:         }
34:         super
35:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.