るりまサーチ

最速Rubyリファレンスマニュアル検索!
55件ヒット [1-55件を表示] (0.120秒)
トップページ > クエリ:-[x] > クエリ:r[x] > クエリ:text[x] > クエリ:meta[x]

別のキーワード

  1. _builtin to_r
  2. open3 pipeline_r
  3. matrix elements_to_r
  4. fileutils rm_r
  5. fileutils cp_r

ライブラリ

モジュール

キーワード

検索結果

OpenURI::Meta#meta -> Hash (24237.0)

ヘッダを収録したハッシュを返します。

...//emlist[例][ruby]{
r
equire 'open-uri'
open('http://example.com/') {|f|
p f.meta
#=> {"date"=>"Sun, 04 May 2008 11:26:40 GMT",
# "content-type"=>"text/html;charset=utf-8",
# "server"=>"Apache/2.0.54 (Debian GNU/Linux) mod_ssl/2.0.54 OpenSSL/0.9.7e",
# "transfer-encoding"=>"chun...
...//emlist[例][ruby]{
r
equire 'open-uri'
URL.open('http://example.com/') {|f|
p f.meta
#=> {"date"=>"Sun, 04 May 2008 11:26:40 GMT",
# "content-type"=>"text/html;charset=utf-8",
# "server"=>"Apache/2.0.54 (Debian GNU/Linux) mod_ssl/2.0.54 OpenSSL/0.9.7e",
# "transfer-encoding"=>"ch...

open-uri (12114.0)

http/ftp に簡単にアクセスするためのクラスです。 Kernel.#open を再定義します。

...スです。
Kernel.#open を再定義します。

=== 使用例

http/ftp の URL を、普通のファイルのように開けます。

r
equire 'open-uri'
open("http://www.ruby-lang.org/") {|f|
f.each_line {|line| p line}
}

開いたファイルオブジェクトは StringIO もしく...
...が OpenURI::Meta モジュールで拡張されていて、メタ情報を獲得する
メソッドが使えます。

r
equire 'open-uri'
open("http://www.ruby-lang.org/en") {|f|
f.each_line {|line| p line}
p f.base_uri # <URI::HTTP:0x40e6ef2 URL:http://www.ruby-lang.org/en/>...
...# "text/html"
p f.charset # "iso-8859-1"
p f.content_encoding # []
p f.last_modified # Thu Dec 05 02:45:02 UTC 2002
}

ハッシュ引数で、追加のヘッダフィールドを指定できます。

r
equire 'open-uri'
open("http://www.ruby-lang.org/en/",
"User-Ag...
...

http/ftp の URL を、普通のファイルのように開けます。

r
equire 'open-uri'
URI.open("http://www.ruby-lang.org/") {|f|
f.each_line {|line| p line}
}

開いたファイルオブジェクトは StringIO もしくは Tempfile で
すが OpenURI::Meta モジュールで...
...が使えます。

r
equire 'open-uri'
URI.open("http://www.ruby-lang.org/en") {|f|
f.each_line {|line| p line}
p f.base_uri # <URI::HTTP:0x40e6ef2 URL:http://www.ruby-lang.org/en/>
p f.content_type # "text/html"
p f.charset # "iso-8859-1"
p f.content_enc...
...ールドを指定できます。

r
equire 'open-uri'
URI.open("http://www.ruby-lang.org/en/",
"User-Agent" => "Ruby/#{RUBY_VERSION}",
"From" => "foo@bar.invalid",
"Referer" => "http://www.ruby-lang.org/") {|f|
...
}

http_proxy, ftp_proxy, no_proxy などの環境変数は、...

OpenURI::Meta#charset -> String | nil (9270.0)

対象となるリソースの文字コードを文字列で返します。Content-Type ヘッダの文字コード情報が使われます。 文字列は小文字へと変換されています。

...nt-Type ヘッダの文字コード情報が使われます。
文字列は小文字へと変換されています。

Content-Type ヘッダがない場合は、nil を返します。ただし、ブロックが与えられている場合は、
その結果を返します。また対象となる URI...
...身のタイプが text である場合は、
2616 3.7.1 で定められているとおり、文字列 "iso-8859-1" を返します。

//emlist[例][ruby]{
r
equire 'open-uri'
open("http://www.ruby-lang.org/en") {|f|
p f.content_type # => "text/html"
p f.charset # => "iso-8859-1"
}
//}...
...のタイプが text である場合は、
2616 3.7.1 で定められているとおり、文字列 "iso-8859-1" を返します。

//emlist[例][ruby]{
r
equire 'open-uri'
URI.open("http://www.ruby-lang.org/en") {|f|
p f.content_type # => "text/html"
p f.charset # => "iso-8859-1"
}
//}...

OpenURI::Meta#charset { ... } -> String (9270.0)

対象となるリソースの文字コードを文字列で返します。Content-Type ヘッダの文字コード情報が使われます。 文字列は小文字へと変換されています。

...nt-Type ヘッダの文字コード情報が使われます。
文字列は小文字へと変換されています。

Content-Type ヘッダがない場合は、nil を返します。ただし、ブロックが与えられている場合は、
その結果を返します。また対象となる URI...
...身のタイプが text である場合は、
2616 3.7.1 で定められているとおり、文字列 "iso-8859-1" を返します。

//emlist[例][ruby]{
r
equire 'open-uri'
open("http://www.ruby-lang.org/en") {|f|
p f.content_type # => "text/html"
p f.charset # => "iso-8859-1"
}
//}...
...のタイプが text である場合は、
2616 3.7.1 で定められているとおり、文字列 "iso-8859-1" を返します。

//emlist[例][ruby]{
r
equire 'open-uri'
URI.open("http://www.ruby-lang.org/en") {|f|
p f.content_type # => "text/html"
p f.charset # => "iso-8859-1"
}
//}...

OpenURI::Meta#content_type -> String (6282.0)

対象となるリソースの Content-Type を文字列で返します。Content-Type ヘッダの情報が使われます。 Content-Type ヘッダがない場合は、"application/octet-stream" を返します。

...Content-Type を文字列で返します。Content-Type ヘッダの情報が使われます。
Content-Type ヘッダがない場合は、"application/octet-stream" を返します。

//emlist[例][ruby]{
r
equire 'open-uri'
open('http://www.ruby-lang.org/') {|f|
p f.content_type #=> "text/html"...
...ntent-Type を文字列で返します。Content-Type ヘッダの情報が使われます。
Content-Type ヘッダがない場合は、"application/octet-stream" を返します。

//emlist[例][ruby]{
r
equire 'open-uri'
URI.open('http://www.ruby-lang.org/') {|f|
p f.content_type #=> "text/htm...

絞り込み条件を変える