class Kudzu::Agent::Util::ContentTypeParser

Public Class Methods

parse(content_type) click to toggle source
# 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

Private Class Methods

unquote(str) click to toggle source
# File lib/kudzu/agent/util/content_type_parser.rb, line 17
def unquote(str)
  if str =~ /^"(.*?)"$/
    $1.gsub(/\\(.)/, '\1')
  else
    str
  end
end