ライブラリ
- ビルトイン (26)
-
net
/ http (22) - open-uri (77)
-
rubygems
/ remote _ fetcher (11)
クラス
-
Gem
:: RemoteFetcher (11) -
Net
:: HTTPResponse (22) - Object (26)
モジュール
-
OpenURI
:: Meta (55) -
OpenURI
:: OpenRead (22)
キーワード
- charset (22)
-
content
_ encoding (11) -
content
_ type (11) -
open
_ uri _ or _ path (11) - read (11)
-
read
_ body (22) - status (11)
- then (12)
-
yield
_ self (14)
検索結果
先頭5件
- OpenURI
:: OpenRead # open(mode = & # 39;r& # 39; , perm = nil , options = {}) -> StringIO - Gem
:: RemoteFetcher # open _ uri _ or _ path(uri , last _ modified = nil , head = false , depth = 0) -> StringIO | File - OpenURI
:: OpenRead # read(options = {}) -> String - OpenURI
:: Meta # charset -> String | nil - OpenURI
:: Meta # charset { . . . } -> String
-
OpenURI
:: OpenRead # open(mode = & # 39;r& # 39; , perm = nil , options = {}) -> StringIO (27265.0) -
自身が表すリソースを取得して StringIO オブジェクトとして返します。 OpenURI.open_uri(self, *rest, &block) と同じです。
...ースを取得して StringIO オブジェクトとして返します。
OpenURI.open_uri(self, *rest, &block) と同じです。
ブロックを与えた場合は StringIO オブジェクトを引数としてブロックを
評価します。ブロックの終了時に StringIO は close され......値である StringIO オブジェクトは OpenURI::Meta モジュールで extend されています。
@param mode モードを文字列で与えます。Kernel.#open と同じです。
@param perm 無視されます。
@param options ハッシュを与えます。
@raise OpenURI::HTTPError......対象となる URI のスキームが http であり、かつリソースの取得に
失敗した時に発生します。
@raise Net::FTPError 対象となる URI のスキームが ftp であり、かつリソースの取得に失敗した時に
Net... -
Gem
:: RemoteFetcher # open _ uri _ or _ path(uri , last _ modified = nil , head = false , depth = 0) -> StringIO | File (12436.0) -
@param uri URI を指定します。
...@param uri URI を指定します。
@param last_modified 最終更新時刻を指定します。
@param head 真を指定するとヘッダ情報のみ取得します。
@param depth 現在のリダイレクト回数を指定します。
@raise Gem::RemoteFetcher::FetchError デフォルトで... -
OpenURI
:: OpenRead # read(options = {}) -> String (9148.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... -
OpenURI
:: Meta # charset -> String | nil (6133.0) -
対象となるリソースの文字コードを文字列で返します。Content-Type ヘッダの文字コード情報が使われます。 文字列は小文字へと変換されています。
...返します。また対象となる URI のスキームが HTTP であり、自身のタイプが text である場合は、
2616 3.7.1 で定められているとおり、文字列 "iso-8859-1" を返します。
//emlist[例][ruby]{
require 'open-uri'
URI.open("http://www.ruby-lang.org/en") {|f|... -
OpenURI
:: Meta # charset { . . . } -> String (6133.0) -
対象となるリソースの文字コードを文字列で返します。Content-Type ヘッダの文字コード情報が使われます。 文字列は小文字へと変換されています。
...返します。また対象となる URI のスキームが HTTP であり、自身のタイプが text である場合は、
2616 3.7.1 で定められているとおり、文字列 "iso-8859-1" を返します。
//emlist[例][ruby]{
require 'open-uri'
URI.open("http://www.ruby-lang.org/en") {|f|... -
OpenURI
:: Meta # charset -> String | nil (6127.0) -
対象となるリソースの文字コードを文字列で返します。Content-Type ヘッダの文字コード情報が使われます。 文字列は小文字へと変換されています。
...返します。また対象となる URI のスキームが HTTP であり、自身のタイプが text である場合は、
2616 3.7.1 で定められているとおり、文字列 "iso-8859-1" を返します。
//emlist[例][ruby]{
require 'open-uri'
open("http://www.ruby-lang.org/en") {|f|
p... -
OpenURI
:: Meta # charset { . . . } -> String (6127.0) -
対象となるリソースの文字コードを文字列で返します。Content-Type ヘッダの文字コード情報が使われます。 文字列は小文字へと変換されています。
...返します。また対象となる URI のスキームが HTTP であり、自身のタイプが text である場合は、
2616 3.7.1 で定められているとおり、文字列 "iso-8859-1" を返します。
//emlist[例][ruby]{
require 'open-uri'
open("http://www.ruby-lang.org/en") {|f|
p... -
OpenURI
:: Meta # content _ encoding -> [String] (6126.0) -
対象となるリソースの Content-Encoding を文字列の配列として返します。 Content-Encoding ヘッダがない場合は、空の配列を返します。
...るリソースの 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 # content _ type -> String (6126.0) -
対象となるリソースの Content-Type を文字列で返します。Content-Type ヘッダの情報が使われます。 Content-Type ヘッダがない場合は、"application/octet-stream" を返します。
...を文字列で返します。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/html"
}
//}... -
OpenURI
:: Meta # status -> [String] (6126.0) -
対象となるリソースのステータスコードと reason phrase を文字列の配列として返します。
...対象となるリソースのステータスコードと reason phrase を文字列の配列として返します。
//emlist[例][ruby]{
require 'open-uri'
URI.open('http://example.com/') {|f|
p f.status #=> ["200", "OK"]
}
//}... -
OpenURI
:: Meta # content _ encoding -> [String] (6120.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"]
}
//}... -
OpenURI
:: Meta # content _ type -> String (6120.0) -
対象となるリソースの Content-Type を文字列で返します。Content-Type ヘッダの情報が使われます。 Content-Type ヘッダがない場合は、"application/octet-stream" を返します。
...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"
}
//}... -
OpenURI
:: Meta # status -> [String] (6120.0) -
対象となるリソースのステータスコードと reason phrase を文字列の配列として返します。
...対象となるリソースのステータスコードと reason phrase を文字列の配列として返します。
//emlist[例][ruby]{
require 'open-uri'
open('http://example.com/') {|f|
p f.status #=> ["200", "OK"]
}
//}... -
Net
:: HTTPResponse # read _ body(dest=nil) -> String|nil (156.0) -
ブロックを与えなかった場合にはエンティティボディを 文字列で返します。 ブロックを与えた場合には エンティティボディを少しずつ取得して順次ブロックに 文字列で与えます。
...ruby]{
require 'net/http'
uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.read_body[0..10] # => "<!doctype h"
//}
//emlist[例2 ブロックを与えて大きいファイルを取得][ruby]{
require 'net/http'
uri = URI.parse('http://www.exampl.......com/path/to/big.file')
Net::HTTP.start(uri.host, uri.port) do |http|
File.open("/path/to/big.file", "w") do |f|
# Net::HTTP#request_get と Net::HTTPResponse#read_body で少しずつ読み書き。メモリ消費が少ない。
http.request_get(uri.path) do |response|
response.read... -
Net
:: HTTPResponse # read _ body {|str| . . . . } -> () (56.0) -
ブロックを与えなかった場合にはエンティティボディを 文字列で返します。 ブロックを与えた場合には エンティティボディを少しずつ取得して順次ブロックに 文字列で与えます。
...ruby]{
require 'net/http'
uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.read_body[0..10] # => "<!doctype h"
//}
//emlist[例2 ブロックを与えて大きいファイルを取得][ruby]{
require 'net/http'
uri = URI.parse('http://www.exampl.......com/path/to/big.file')
Net::HTTP.start(uri.host, uri.port) do |http|
File.open("/path/to/big.file", "w") do |f|
# Net::HTTP#request_get と Net::HTTPResponse#read_body で少しずつ読み書き。メモリ消費が少ない。
http.request_get(uri.path) do |response|
response.read...