Ruby 2.3.0 リファレンスマニュアル > ライブラリ一覧 > open-uriライブラリ > OpenURI::Metaモジュール > content_type
content_type -> String
[permalink][rdoc]対象となるリソースの Content-Type を文字列で返します。Content-Type ヘッダの情報が使われます。 Content-Type ヘッダがない場合は、"application/octet-stream" を返します。
require 'open-uri'
open('http://www.ruby-lang.org/') {|f|
p f.content_type #=> "text/html"
}