種類
- 特異メソッド (130)
- インスタンスメソッド (120)
- 文書 (81)
- クラス (24)
- ライブラリ (12)
クラス
-
Net
:: HTTP (24) -
Net
:: HTTPGenericRequest (36) -
Net
:: HTTPResponse (24) - OptionParser (24)
-
URI
:: FTP (12) -
URI
:: Generic (36) -
URI
:: HTTP (12) -
WEBrick
:: Cookie (24)
モジュール
- OpenURI (24)
-
RubyVM
:: AbstractSyntaxTree (10) - URI (24)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) - CSV (12)
-
NEWS for Ruby 2
. 5 . 0 (8) -
NEWS for Ruby 2
. 6 . 0 (7) -
NEWS for Ruby 2
. 7 . 0 (6) - XPathParser (12)
-
body
_ stream (12) -
body
_ stream= (12) -
get
_ print (24) - join (12)
-
net
/ http (12) - new (24)
-
open
_ uri (24) -
parse
_ file (10) -
program
_ name (12) -
program
_ name= (12) -
read
_ body (24) -
request
_ uri (12) -
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 3 feature (12) -
ruby 1
. 8 . 4 feature (12) -
ruby 1
. 8 . 5 feature (12) - select (12)
検索結果
先頭5件
-
net
/ http (54.0) -
汎用データ転送プロトコル HTTP を扱うライブラリです。 実装は 2616 に基きます。
...URI を使う][ruby]{
require 'net/http'
require 'uri'
print Net::HTTP.get(URI.parse('http://www.example.com/index.html'))
//}
//emlist[例3: より汎用的な例][ruby]{
require 'net/http'
require 'uri'
url = URI.parse('http://www.example.com/index.html')
res = Net::HTTP.start(url.host, url.port......puts res.body
//}
//emlist[例4: 上の例よりさらに汎用的な例][ruby]{
require 'net/http'
url = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(url.path)
res = Net::HTTP.start(url.host, url.port) {|http|
http.request(req)
}
puts res.body
//}
==== フォーム......'uri'
#例1: POSTするだけ
res = Net::HTTP.post_form(URI.parse('http://www.example.com/search'),
{'q'=>'ruby', 'max'=>'50'})
puts res.body
#例2: 認証付きで POST する
res = Net::HTTP.post_form(URI.parse('http://jack:pass@www.example.com/todo.cgi'),... -
URI
:: HTTP # request _ uri -> String (50.0) -
自身の「path + '?' + query」を文字列で返します。 query が nil である場合は、自身の path を返します。
...自身の「path + '?' + query」を文字列で返します。
query が nil である場合は、自身の path を返します。
path が空である場合には、path は「'/'」であるとします。
例:
require 'uri'
u = URI.parse("http://example.com/search?q=xxx")
p u.request_u... -
ruby 1
. 8 . 3 feature (48.0) -
ruby 1.8.3 feature *((<ruby 1.8 feature>)) *((<ruby 1.8.2 feature>))
...-e:1:in `join': can't convert Fixnum into String (TypeError)
from -e:1
=== 2005-09-16
: File.extname [ruby] [compat]
与えられた pathname がピリオドで終る場合、ピリオドではなく空の文字列を返すようになりました。
$ ruby-1.8.2 -e 'p File.extn......= 2005-08-29
: Time.parse [lib] [compat]
Time.parse が小数点以下の秒も扱えるようになりました。((<ruby-talk:153859>))
$ ruby-1.8.2 -r time -e 'p Time.parse("23 Aug 2005 19:00:01.1").to_f'
1124791201.0
$ ruby-1.8.3 -r time -e 'p Time.parse("23 Aug 2005 19:00......] [new]
: GDBM#closed? [lib] [new]
: SDBM#closed? [lib] [new]
=== 2005-06-16
: Time.parse [lib] [compat]
うるう秒 "Fri Jan 1 08:59:60 +0900 1999" をサポートしている環境において、Time.parse が
適切に振舞うようになりました。
=== 2005-06-08
: Curses.insertln... -
NEWS for Ruby 2
. 5 . 0 (30.0) -
NEWS for Ruby 2.5.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...になりました 11286
* File
* File.open :newline オプションを指定するとテキストモードになります 13350
* File#path はFile::Constants::TMPFILE付きで開いたファイルに対して IOError を発生させます
13568
* File.stat, File.exist? など......つか読み込んでから、Coverage.result を使って結果を取得することができます。
//emlist[][ruby]{
Coverage.result
#=> { "/path/to/file.rb"=>
# { :lines => [1, 2, 0, nil, ...],
# :branches =>
# { [:if, 0, 2, 1, 6, 4] =>
# { [:then, 1, 3, 2, 3, 8]......す。
* pathname
* Pathname#glob を追加 7360
* psych
* Psych 3.0.2 に更新しました
* Convert fallback option to a keyword argument
https://github.com/ruby/psych/pull/342
* Add :symbolize_names option to Psych.load, Psych.safe_load like JSON.parse
h... -
NEWS for Ruby 2
. 6 . 0 (30.0) -
NEWS for Ruby 2.6.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...* RubyVM::AbstractSyntaxTree
* 新規メソッド
* RubyVM::AbstractSyntaxTree.parse は文字列をパースして AST ノードを返します。 [実験的]
* RubyVM::AbstractSyntaxTree.parse_file はファイルをパースして AST ノードを返します。 [実験的]......proc やメソッドに対応する AST ノードを返します。 [実験的]
* RubyVM
* 新規メソッド
* RubyVM.resolve_feature_path は "require(feature)" で読み込むファイルを
特定します。 [実験的] 15230
* String
* String#crypt は非推奨に......い。
* いくつかの XPath 実装を改善:
* concat() 関数: 結合前に全ての引数を文字列化
* string() 関数: コンテキストノードをサポート
* string() 関数: 処理命令 (PI) ノードをサポート
* XPath 2.0 で"*:#{ELEMENT_NAME}" 記... -
Net
:: HTTPResponse # read _ body {|str| . . . . } -> () (30.0) -
ブロックを与えなかった場合にはエンティティボディを 文字列で返します。 ブロックを与えた場合には エンティティボディを少しずつ取得して順次ブロックに 文字列で与えます。
...onse(URI.parse(uri))
response.read_body[0..10] # => "<!doctype h"
//}
//emlist[例2 ブロックを与えて大きいファイルを取得][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/path/to/big.file')
Net::HTTP.start(uri.host, uri.port) do |http|
File.open("/path/to/big.f......|
# Net::HTTP#request_get と Net::HTTPResponse#read_body で少しずつ読み書き。メモリ消費が少ない。
http.request_get(uri.path) do |response|
response.read_body do |s|
f.write(s)
end
end
end
end
//}
一度ブロックを与えずにこのメソッ... -
Net
:: HTTPResponse # read _ body(dest=nil) -> String|nil (30.0) -
ブロックを与えなかった場合にはエンティティボディを 文字列で返します。 ブロックを与えた場合には エンティティボディを少しずつ取得して順次ブロックに 文字列で与えます。
...onse(URI.parse(uri))
response.read_body[0..10] # => "<!doctype h"
//}
//emlist[例2 ブロックを与えて大きいファイルを取得][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/path/to/big.file')
Net::HTTP.start(uri.host, uri.port) do |http|
File.open("/path/to/big.f......|
# Net::HTTP#request_get と Net::HTTPResponse#read_body で少しずつ読み書き。メモリ消費が少ない。
http.request_get(uri.path) do |response|
response.read_body do |s|
f.write(s)
end
end
end
end
//}
一度ブロックを与えずにこのメソッ... -
CSV (24.0)
-
このクラスは CSV ファイルやデータに対する完全なインターフェイスを提供します。
...行ずつ
CSV.parse(csv_text) do |row|
p row
end
# => ["Ruby", "1995"]
# ["Rust", "2010"]
# 文字列から一度に
p CSV.parse(csv_text)
# => [["Ruby", "1995"], ["Rust", "2010"]]
//}
=== 書き込み
//emlist[][ruby]{
require 'csv'
# ファイルへ書き込み
CSV.open("path/to/file.csv"......# ...
end
//}
=== 一行変換
//emlist[][ruby]{
require 'csv'
csv_string = ["CSV", "data"].to_csv # => "CSV,data"
csv_array = "CSV,String".parse_csv # => ["CSV", "String"]
//}
=== ショートカット
//emlist[][ruby]{
require 'csv'
CSV { |csv_out| csv_out << %w{my data he......17n or Multilingualization)
This new CSV parser is m17n savvy. The parser works in the Encoding of the IO
or String object being read from or written to. Your data is never transcoded
(unless you ask Ruby to transcode it for you) and will literally be parsed in
the Encoding it is in. Thus CSV wi... -
Net
:: HTTP . get _ print(uri) -> () (19.0) -
指定した対象から HTTP でエンティティボディを取得し、 $stdout に出力します。
...指定方法は URI で指定するか、
(host, path, port) で指定するかのいずれかです。
@param uri データの取得対象を URI で指定します。
@param host 接続先のホストを文字列で指定します。
@param path データの存在するパスを文字列で指定......るポートを整数で指定します。
@see Net::HTTP.get
=== 例
//emlist[][ruby]{
require 'net/http'
require 'uri'
Net::HTTP.get_print URI.parse('http://www.example.com/index.html')
//}
もしくは
//emlist[][ruby]{
require 'net/http'
Net::HTTP.get_print 'www.example.com', '/index.html'
/... -
Net
:: HTTPGenericRequest # body _ stream -> object (18.0) -
サーバに送るリクエストのエンティティボディを IO オブジェクトなどのストリームで設定します。 f は read(size) メソッドが定義されている必要があります。
....parse('http://www.example.com/index.html')
post = Net::HTTP::Post.new(uri.request_uri)
File.open("/path/to/test", 'rb') do |f|
# 大きなファイルを扱う際にメモリ消費を少なくできる
post.body_stream = f
post["Content-Length"] = f.size
end
post.body_stream # => #<File:/path...