るりまサーチ

最速Rubyリファレンスマニュアル検索!
97件ヒット [1-97件を表示] (0.024秒)

別のキーワード

  1. matrix index
  2. matrix find_index
  3. _builtin find_index
  4. _builtin index
  5. matrix each_with_index

ライブラリ

クラス

モジュール

検索結果

Net::HTTPHeader#fetch(key) -> String (18145.0)

key ヘッダフィールドを返します。

...指定します。
@raise IndexError 引数defaultもブロックも与えられてない時、キーの探索に 失敗すると発生します。

//emlist[例 key のみ指定。key が存在する][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::G...
...et.new(uri.request_uri)
req.fetch("user-agent") # => "Ruby"
//}

//emlist[例 key のみ指定。key が存在しない][ruby]{
require 'net/http'

begin
req.fetch("content-length")
rescue => e
e # => #<KeyError: key not found: "content-length">
end
//}

//emlist[例 key , default を指定][rub...
...e.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.fetch("content-length", "default") # => "default"
//}

//emlist[例 key とブロックを指定][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.fetch("cont...

Net::HTTPHeader#fetch(key) {|hash| .... } -> String (18145.0)

key ヘッダフィールドを返します。

...指定します。
@raise IndexError 引数defaultもブロックも与えられてない時、キーの探索に 失敗すると発生します。

//emlist[例 key のみ指定。key が存在する][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::G...
...et.new(uri.request_uri)
req.fetch("user-agent") # => "Ruby"
//}

//emlist[例 key のみ指定。key が存在しない][ruby]{
require 'net/http'

begin
req.fetch("content-length")
rescue => e
e # => #<KeyError: key not found: "content-length">
end
//}

//emlist[例 key , default を指定][rub...
...e.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.fetch("content-length", "default") # => "default"
//}

//emlist[例 key とブロックを指定][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.fetch("cont...

Net::HTTPHeader#fetch(key, default) -> String (18145.0)

key ヘッダフィールドを返します。

...指定します。
@raise IndexError 引数defaultもブロックも与えられてない時、キーの探索に 失敗すると発生します。

//emlist[例 key のみ指定。key が存在する][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::G...
...et.new(uri.request_uri)
req.fetch("user-agent") # => "Ruby"
//}

//emlist[例 key のみ指定。key が存在しない][ruby]{
require 'net/http'

begin
req.fetch("content-length")
rescue => e
e # => #<KeyError: key not found: "content-length">
end
//}

//emlist[例 key , default を指定][rub...
...e.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.fetch("content-length", "default") # => "default"
//}

//emlist[例 key とブロックを指定][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.fetch("cont...

Array#fetch(nth) -> object (18127.0)

nth 番目の要素を返します。

...返します。

Array#[] (nth) とは nth 番目の要素が存在しない場合の振舞いが異
なります。最初の形式では、例外 IndexError が発生します。
二番目の形式では、引数 ifnone を返します。
三番目の形式では、ブロックを評価した結果...
...e IndexError 引数 ifnone もブロックも指定しておらず、 nth 番目の要
素も存在しなかった場合に発生します。

//emlist[例][ruby]{
a = [1, 2, 3, 4, 5]
begin
p a.fetch(10)
rescue IndexError => err
puts err #=> index 10 out of array
end

p a.fetch...
...(10, 999) #=> 999

result = a.fetch(10){|nth|
print "#{nth} はありません。\n"
999
}
p result #=> 999
//}...

Array#fetch(nth) {|nth| ... } -> object (18127.0)

nth 番目の要素を返します。

...返します。

Array#[] (nth) とは nth 番目の要素が存在しない場合の振舞いが異
なります。最初の形式では、例外 IndexError が発生します。
二番目の形式では、引数 ifnone を返します。
三番目の形式では、ブロックを評価した結果...
...e IndexError 引数 ifnone もブロックも指定しておらず、 nth 番目の要
素も存在しなかった場合に発生します。

//emlist[例][ruby]{
a = [1, 2, 3, 4, 5]
begin
p a.fetch(10)
rescue IndexError => err
puts err #=> index 10 out of array
end

p a.fetch...
...(10, 999) #=> 999

result = a.fetch(10){|nth|
print "#{nth} はありません。\n"
999
}
p result #=> 999
//}...

絞り込み条件を変える

Array#fetch(nth, ifnone) -> object (18127.0)

nth 番目の要素を返します。

...返します。

Array#[] (nth) とは nth 番目の要素が存在しない場合の振舞いが異
なります。最初の形式では、例外 IndexError が発生します。
二番目の形式では、引数 ifnone を返します。
三番目の形式では、ブロックを評価した結果...
...e IndexError 引数 ifnone もブロックも指定しておらず、 nth 番目の要
素も存在しなかった場合に発生します。

//emlist[例][ruby]{
a = [1, 2, 3, 4, 5]
begin
p a.fetch(10)
rescue IndexError => err
puts err #=> index 10 out of array
end

p a.fetch...
...(10, 999) #=> 999

result = a.fetch(10){|nth|
print "#{nth} はありません。\n"
999
}
p result #=> 999
//}...

net/http (54.0)

汎用データ転送プロトコル HTTP を扱うライブラリです。 実装は 2616 に基きます。

...com', '/index.html')
//}

//emlist[例2: 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) {|http|
http.get('/index.html')
}
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,...
...==== リダイレクトに対応する
以下の例の fetch はリダイレクトに対応しています。
limit 回数以上リダイレクトしたらエラーにします。

//emlist[例][ruby]{
require 'net/http'
require 'uri'

def fetch(uri_str, limit = 10)
# You should choose better exc...

1.6.8から1.8.0への変更点(まとめ) (24.0)

1.6.8から1.8.0への変更点(まとめ) * ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加された定数>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張されたクラス/メソッド(互換性のある変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/変更されたクラス/メソッド(互換性のない変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/文法の変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/正規表現>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Marshal>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Windows 対応>)) * ((<1.6.8から1.8.0への変更点(まとめ)/廃止された(される予定の)機能>)) * ((<1.6.8から1.8.0への変更点(まとめ)/ライブラリ>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張ライブラリAPI>)) * ((<1.6.8から1.8.0への変更点(まとめ)/バグ修正>)) * ((<1.6.8から1.8.0への変更点(まとめ)/サポートプラットフォームの追加>))

...|Array/transpose>)) [new]

追加

: ((<Array#zip|Enumerable/zip>)) [new]
: ((<Enumerable#zip|Enumerable/zip>)) [new]

追加

: ((<Array#fetch|Array/fetch>)) [new]

追加

: ((<Array#insert|Array/insert>)) [new]

追加 ((<ruby-talk:14289>))

(({ary[n,0] = [other,...]})) と同...
...[new]
: ((<aStruct#values_at|Struct/values_at>)) [new]

ruby 1.6 の ((<indexes|Array/indexes>)) は、values_at というメソッド
名になりました(ruby 1.7 では block なし ((<select|Array/select>)) が
index
es の代わりでしたが、こちらも使用すると警告が出ま...
...映された上で obsolete)

# str =~ arg だけは、arg が文字列のとき、
# Regexp.compile(Regexp.quote(arg)) =~ str と等価な str.index(arg) が
# 実行されます(したがって、$~ は設定されません)。

$; の指定に正規表現が許されるようになりま...

NEWS for Ruby 2.3.0 (12.0)

NEWS for Ruby 2.3.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...block は IO#read_nonblock と同じように `exception: false' オプションをサポートします
11358

* Array
* Array#bsearch_index を追加
10730
* Array#dig を追加
11643

* Comparable
* Comparable#==はもはや例外を rescue しません
768...
...1773

* File
* File.mkfifo
11536
* O_TMPFILE に対応する File::TMPFILE(File::Constants::TMPFILE) を追加

* Hash
* Hash#fetch_values を追加
10017
* Hash#dig を追加
11643
* Hash#<=, Hash#<, Hash#>=, Hash#> を追加
10984
* Hash#to_proc...
...10958

* File::Stat
* Windows では File::Stat#ino は常に 0 を返していましたが、
BY_HANDLE_FILE_INFORMATION.nFileIndexHigh/Low を返すようになりました。
11216

* Hash
* Hash#inspect はその要素の文字列が Encoding.default_external と...