種類
- インスタンスメソッド (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
- OpenURI
:: Meta # content _ encoding -> [String] - OpenURI
:: OpenRead # open(mode = & # 39;r& # 39; , perm = nil , options = {}) {|sio| . . . } -> nil - OpenURI
. open _ uri(name , mode = & # 39;r& # 39; , perm = nil , options = {}) -> StringIO - OpenURI
. open _ uri(name , mode = & # 39;r& # 39; , perm = nil , options = {}) {|sio| . . . } -> nil
-
open-uri (56138.0)
-
http/ftp に簡単にアクセスするためのクラスです。 Kernel.#open を再定義します。
...Kernel.#open を再定義します。
=== 使用例
http/ftp の URL を、普通のファイルのように開けます。
require 'open-uri'
open("http://www.ruby-lang.org/") {|f|
f.each_line {|line| p line}
}
開いたファイルオブジェクトは StringIO もしくは Tempfile......が OpenURI::Meta モジュールで拡張されていて、メタ情報を獲得する
メソッドが使えます。
require '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/>......ntent_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'
open("http://www.ruby-lang.org/en/......通のファイルのように開けます。
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 # []......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" => "htt... -
OpenURI
:: Meta # content _ encoding -> [String] (29550.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
:: OpenRead # open(mode = & # 39;r& # 39; , perm = nil , options = {}) {|sio| . . . } -> nil (23400.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::FTPError... -
OpenURI
. open _ uri(name , mode = & # 39;r& # 39; , perm = nil , options = {}) -> StringIO (23360.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
* :progress_p......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 (23360.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
* :progress_p......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
:: OpenRead # open(mode = & # 39;r& # 39; , perm = nil , options = {}) -> StringIO (23300.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::FTPError... -
OpenURI
:: Meta # base _ uri -> URI (20424.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'
URI.open('http://www.ruby-lang.org/') {|f|
p f.base_uri
#=> #<URI::HTTP:0......xb7043aa0 URL:http://www.ruby-lang.org/en/>
}
//}... -
OpenURI
:: Meta # content _ type -> String (20382.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_type #=> "text/html......Content-Type を文字列で返します。Content-Type ヘッダの情報が使われます。
Content-Type ヘッダがない場合は、"application/octet-stream" を返します。
//emlist[例][ruby]{
require 'open-uri'
URI.open('http://www.ruby-lang.org/') {|f|
p f.content_type #=> "text/h... -
OpenURI
:: Meta # last _ modified -> Time | nil (20328.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 # read(options = {}) -> String (20312.0) -
自身が表す内容を読み込んで文字列として返します。 self.open(options={}) {|io| io.read } と同じです。 このメソッドによって返される文字列は OpenURI::Meta によって extend されています。
...self.open(options={}) {|io| io.read } と同じです。
このメソッドによって返される文字列は OpenURI::Meta
によって extend されています。
@param options ハッシュを与えます。
require 'open-uri'
uri = URI.parse('http://www.example.com/')
str = uri.read......p str.is_a?(OpenURI::Meta) # => true
p str.content_type...