Tmail i content-type

Witam,
próbuję wydobyć charset z nagłówka Content-Type pewnego maila. Nagłówek ten wygląda następująco:

Content-Type: text/plain; charset=utf-8;
format=flowed reply-type=original

Próbowałam na różne sposoby:

mail.header['content-type'] # => #<TMail::ContentTypeHeader "text/plain; charset=utf-8;\n format=flowed\treply-type=original"> mail.header['content-type']['charset'] # => nil
aż wreszcie mail.header[‘content-type’].to_s wyrzuciło

NoMethodError: You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.each from /usr/lib/ruby/gems/1.8/gems/tmail-1.2.3.1/lib/tmail/header.rb:816:in `do_accept' from /usr/lib/ruby/gems/1.8/gems/tmail-1.2.3.1/lib/tmail/header.rb:165:in `accept' from /usr/lib/ruby/gems/1.8/gems/tmail-1.2.3.1/lib/tmail/encode.rb:98:in `accept_strategy' from /usr/lib/ruby/gems/1.8/gems/tmail-1.2.3.1/lib/tmail/encode.rb:91:in `to_s' from (irb):13
Możecie mi podpowiedzieć jak wydobyć ten charset?

mail.charset nie działa?

http://tmail.rubyforge.org/rdoc/classes/TMail/Mail.html#M000097 twierdzi że powinno :wink:

W ogóle dokumentacja twierdzi że wszystko powinno działać :slight_smile: Nie, mail.charset też nie działa. W końcu odkryłam, że chociaż mail.header[‘content-type’].to_s nie działa, to działa mail.header[‘content-type’].to_json, a stamtąd już łatwo coś wydobyć choćby wyrażeniem regularnym. Więc problem rozwiązany, chociaż niezbyt elegancko.