Class: Kudzu::Agent::Util::ContentTypeParser

Inherits:
Object
  • Object
show all
Defined in:
lib/kudzu/agent/util/content_type_parser.rb

Class Method Summary collapse

Class Method Details

.parse(content_type) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/kudzu/agent/util/content_type_parser.rb', line 6

def parse(content_type)
  mime, *kvs = content_type.to_s.split(';').map { |str| str.strip.downcase }
  params = kvs.each_with_object({}) do |kv, hash|
             k, v = kv.to_s.split('=').map { |str| str.strip }
             hash[k.to_sym] = unquote(v) if k && v
           end
  return mime, params
end