Method: Mechanize::PluggableParser#parser
- Defined in:
- lib/mechanize/pluggable_parsers.rb
#parser(content_type) ⇒ Object
Returns the parser registered for the given content_type
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/mechanize/pluggable_parsers.rb', line 100 def parser content_type return default unless content_type parser = @parsers[content_type] return parser if parser mime_type = MIME::Type.new "content-type" => content_type parser = @parsers[mime_type.to_s] || @parsers[mime_type.simplified] || # Starting from mime-types 3.0 x-prefix is deprecated as per IANA (@parsers[MIME::Type.simplified(mime_type.to_s, remove_x_prefix: true)] rescue nil) || @parsers[mime_type.media_type] || default rescue InvalidContentTypeError default end |