種類
- インスタンスメソッド (135)
- 文書 (42)
- 特異メソッド (36)
- モジュール関数 (16)
- ライブラリ (11)
クラス
- Object (14)
モジュール
- Kernel (16)
- OpenURI (22)
-
OpenURI
:: Meta (88) -
OpenURI
:: OpenRead (33) - URI (14)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) -
NEWS for Ruby 2
. 1 . 0 (11) -
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 0 . 0 (4) -
base
_ uri (11) - charset (22)
-
content
_ encoding (11) -
content
_ type (11) -
last
_ modified (11) - open (52)
-
open
_ uri (22) - read (11)
-
ruby 1
. 8 . 3 feature (11) - status (11)
-
yield
_ self (14)
検索結果
先頭5件
-
open-uri (50132.0)
-
http/ftp に簡単にアクセスするためのクラスです。 Kernel.#open を再定義します。
...普通のファイルのように開けます。
require 'open-uri'
open("http://www.ruby-lang.org/") {|f|
f.each_line {|line| p line}
}
開いたファイルオブジェクトは StringIO もしくは Tempfile で
すが OpenURI::Meta モジュールで拡張されていて、メタ情......ire '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/>
p f.content_type # "text/html"
p f.charset # "iso-8859-1"
p f.content_encoding # []
p f.last_modifi......、追加のヘッダフィールドを指定できます。
require 'open-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 などの環......普通のファイルのように開けます。
require 'open-uri'
URI.open("http://www.ruby-lang.org/") {|f|
f.each_line {|line| p line}
}
開いたファイルオブジェクトは StringIO もしくは Tempfile で
すが OpenURI::Meta モジュールで拡張されていて、メタ......。
require '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_encoding # []......p f.last_modified # Thu Dec 05 02:45:02 UTC 2002
}
ハッシュ引数で、追加のヘッダフィールドを指定できます。
require 'open-uri'
URI.open("http://www.ruby-lang.org/en/",
"User-Agent" => "Ruby/#{RUBY_VERSION}",
"From" => "foo@bar.invalid",
"Referer" => "h... -
OpenURI
:: Meta # content _ encoding -> [String] (14350.0) -
対象となるリソースの Content-Encoding を文字列の配列として返します。 Content-Encoding ヘッダがない場合は、空の配列を返します。
...となるリソースの Content-Encoding を文字列の配列として返します。
Content-Encoding ヘッダがない場合は、空の配列を返します。
例:
//emlist[例][ruby]{
require 'open-uri'
open('http://example.com/f.tar.gz') {|f|
p f.content_encoding #=> ["x-gzip"]
}
//}......るリソースの Content-Encoding を文字列の配列として返します。
Content-Encoding ヘッダがない場合は、空の配列を返します。
例:
//emlist[例][ruby]{
require 'open-uri'
URI.open('http://example.com/f.tar.gz') {|f|
p f.content_encoding #=> ["x-gzip"]
}
//}... -
OpenURI
:: Meta # base _ uri -> URI (14324.0) -
リソースの実際の URI を URI オブジェクトとして返します。 リダイレクトされた場合は、リダイレクトされた後のデータが存在する URI を返します。
...際の URI を URI オブジェクトとして返します。
リダイレクトされた場合は、リダイレクトされた後のデータが存在する URI を返します。
//emlist[例][ruby]{
require 'open-uri'
open('http://www.ruby-lang.org/') {|f|
p f.base_uri
#=> #<URI::HTTP:0xb70......43aa0 URL:http://www.ruby-lang.org/en/>
}
//}......際の URI を URI オブジェクトとして返します。
リダイレクトされた場合は、リダイレクトされた後のデータが存在する URI を返します。
//emlist[例][ruby]{
require 'open-uri'
URL.open('http://www.ruby-lang.org/') {|f|
p f.base_uri
#=> #<URI::HTTP:0......xb7043aa0 URL:http://www.ruby-lang.org/en/>
}
//}... -
OpenURI
. open _ uri(name , mode = & # 39;r& # 39; , perm = nil , options = {}) -> StringIO (14260.0) -
URI である文字列 name のリソースを取得して StringIO オブジェクト として返します。
...URI である文字列 name のリソースを取得して StringIO オブジェクト
として返します。
ブロックを与えた場合は StringIO オブジェクトを引数としてブロックを
評価します。ブロックの終了時に StringIO は close されます。nil を返......します。
require 'open-uri'
sio = OpenURI.open_uri('http://www.example.com')
p sio.last_modified
puts sio.read
OpenURI.open_uri('http://www.example.com'){|sio| sio.read }
options には Hash を与えます。理解するハッシュの
キーは以下のシンボル、
* :proxy
*......asic_authentication
* :proxy_http_basic_authentication
* :read_timeout
* :ssl_ca_cert
* :ssl_verify_mode
* :ftp_active_mode
* :redirect
です。
「:content_length_proc」と「:progress_proc」はプログレスバーに
利用されることを想定しています。
require 'open-uri'... -
OpenURI
. open _ uri(name , mode = & # 39;r& # 39; , perm = nil , options = {}) {|sio| . . . } -> nil (14260.0) -
URI である文字列 name のリソースを取得して StringIO オブジェクト として返します。
...URI である文字列 name のリソースを取得して StringIO オブジェクト
として返します。
ブロックを与えた場合は StringIO オブジェクトを引数としてブロックを
評価します。ブロックの終了時に StringIO は close されます。nil を返......します。
require 'open-uri'
sio = OpenURI.open_uri('http://www.example.com')
p sio.last_modified
puts sio.read
OpenURI.open_uri('http://www.example.com'){|sio| sio.read }
options には Hash を与えます。理解するハッシュの
キーは以下のシンボル、
* :proxy
*......asic_authentication
* :proxy_http_basic_authentication
* :read_timeout
* :ssl_ca_cert
* :ssl_verify_mode
* :ftp_active_mode
* :redirect
です。
「:content_length_proc」と「:progress_proc」はプログレスバーに
利用されることを想定しています。
require 'open-uri'... -
OpenURI
:: Meta # last _ modified -> Time | nil (14228.0) -
対象となる URI の最終更新時刻を Time オブジェクトで返します。 Last-Modified ヘッダがない場合は nil を返します。
...対象となる URI の最終更新時刻を Time オブジェクトで返します。
Last-Modified ヘッダがない場合は nil を返します。
例:
//emlist[例][ruby]{
require 'open-uri'
open('http://www.rubyist.net/') {|f|
p f.last_modified
#=> Thu Feb 26 16:54:58 +0900 2004
}
//}......対象となる URI の最終更新時刻を Time オブジェクトで返します。
Last-Modified ヘッダがない場合は nil を返します。
例:
//emlist[例][ruby]{
require 'open-uri'
URI.open('http://www.rubyist.net/') {|f|
p f.last_modified
#=> Thu Feb 26 16:54:58 +0900 2004
}
/... -
OpenURI
:: OpenRead # open(mode = & # 39;r& # 39; , perm = nil , options = {}) {|sio| . . . } -> nil (11300.0) -
自身が表すリソースを取得して StringIO オブジェクトとして返します。 OpenURI.open_uri(self, *rest, &block) と同じです。
...て StringIO オブジェクトとして返します。
OpenURI.open_uri(self, *rest, &block) と同じです。
ブロックを与えた場合は StringIO オブジェクトを引数としてブロックを
評価します。ブロックの終了時に StringIO は close されます。nil を返......である StringIO オブジェクトは OpenURI::Meta モジュールで extend されています。
@param mode モードを文字列で与えます。Kernel.#open と同じです。
@param perm 無視されます。
@param options ハッシュを与えます。
@raise OpenURI::HTTPError 対......象となる URI のスキームが http であり、かつリソースの取得に
失敗した時に発生します。
@raise Net::FTPError 対象となる URI のスキームが ftp であり、かつリソースの取得に失敗した時に
Net::F... -
URI
. open(name , mode = & # 39;r& # 39; , perm = nil , options = {}) -> StringIO | Tempfile | IO (11300.0) -
name が http:// や https://、ftp:// で始まっている文字列なら URI のリソースを 取得した上で StringIO オブジェクトまたは Tempfile オブジェクトとして返します。 返されるオブジェクトは OpenURI::Meta モジュールで extend されています。
...:// や https://、ftp:// で始まっている文字列なら URI のリソースを
取得した上で StringIO オブジェクトまたは Tempfile オブジェクトとして返します。
返されるオブジェクトは OpenURI::Meta モジュールで extend されています。
name に......// で
始まっている文字列なら URI のリソースを取得した上で StringIO オブジェクト
または Tempfile オブジェクトを引数としてブロックを評価します。後は同様です。
引数のオブジェクトは OpenURI::Meta モジュールで extend されて......ptions ハッシュを与えます。詳しくは OpenURI.open_uri を参照してください。
@raise OpenURI::HTTPError 対象となる URI のスキームが http または https であり、
かつリソースの取得に失敗したときに発生します。
@rais... -
OpenURI
:: Meta # content _ type -> String (11282.0) -
対象となるリソースの Content-Type を文字列で返します。Content-Type ヘッダの情報が使われます。 Content-Type ヘッダがない場合は、"application/octet-stream" を返します。
...なるリソースの Content-Type を文字列で返します。Content-Type ヘッダの情報が使われます。
Content-Type ヘッダがない場合は、"application/octet-stream" を返します。
//emlist[例][ruby]{
require 'open-uri'
open('http://www.ruby-lang.org/') {|f|
p f.content......るリソースの Content-Type を文字列で返します。Content-Type ヘッダの情報が使われます。
Content-Type ヘッダがない場合は、"application/octet-stream" を返します。
//emlist[例][ruby]{
require 'open-uri'
URI.open('http://www.ruby-lang.org/') {|f|
p f.conten... -
OpenURI
:: Meta # charset -> String | nil (11264.0) -
対象となるリソースの文字コードを文字列で返します。Content-Type ヘッダの文字コード情報が使われます。 文字列は小文字へと変換されています。
...t-Type ヘッダの文字コード情報が使われます。
文字列は小文字へと変換されています。
Content-Type ヘッダがない場合は、nil を返します。ただし、ブロックが与えられている場合は、
その結果を返します。また対象となる URI......身のタイプが text である場合は、
2616 3.7.1 で定められているとおり、文字列 "iso-8859-1" を返します。
//emlist[例][ruby]{
require '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]{
require 'open-uri'
URI.open("http://www.ruby-lang.org/en") {|f|
p f.content_type # => "text/html"
p f.charset # => "iso-8859-1"
}
//}...