るりまサーチ

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

別のキーワード

  1. _builtin raise
  2. kernel raise
  3. fiber raise
  4. thread raise
  5. e2mmap raise

ライブラリ

クラス

モジュール

キーワード

検索結果

<< < 1 2 3 > >>

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

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

...在しなかった場合に返すべき値を指定します。

@raise TypeError 引数 nth に整数以外の(暗黙の型変換が行えない)オブジェ
クトを指定した場合に発生します。

@raise IndexError 引数 ifnone もブロックも指定しておらず、...
...なかった場合に発生します。

//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 (18134.0)

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

...在しなかった場合に返すべき値を指定します。

@raise TypeError 引数 nth に整数以外の(暗黙の型変換が行えない)オブジェ
クトを指定した場合に発生します。

@raise IndexError 引数 ifnone もブロックも指定しておらず、...
...なかった場合に発生します。

//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
//}...
...しなかった場合に発生します。

//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::HTTPHeader#fetch(key) -> String (18134.0)

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

...ダフィール名を文字列で与えます。
@param default 該当するキーが登録されていない時の返り値を指定します。
@raise IndexError 引数defaultもブロックも与えられてない時、キーの探索に 失敗すると発生します。

//emlist[例 key のみ...
...http://www.example.com/index.html')
req = Net::HTTP::Get.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-lengt...
...: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("content-length") { |e| 99 } # =>...

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

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

...ダフィール名を文字列で与えます。
@param default 該当するキーが登録されていない時の返り値を指定します。
@raise IndexError 引数defaultもブロックも与えられてない時、キーの探索に 失敗すると発生します。

//emlist[例 key のみ...
...http://www.example.com/index.html')
req = Net::HTTP::Get.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-lengt...
...: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("content-length") { |e| 99 } # =>...

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

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

...ダフィール名を文字列で与えます。
@param default 該当するキーが登録されていない時の返り値を指定します。
@raise IndexError 引数defaultもブロックも与えられてない時、キーの探索に 失敗すると発生します。

//emlist[例 key のみ...
...http://www.example.com/index.html')
req = Net::HTTP::Get.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-lengt...
...: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("content-length") { |e| 99 } # =>...

絞り込み条件を変える

PStore#fetch(name, default = PStore::Error) -> object (18132.0)

ルートnameに対応する値を得ます。

...@param name 探索するルート。

@param default name に対応するルートが登録されていない場合に返す値を指定する。

@raise PStore::Error name に対応するルートが登録されていないかつ、
default が与えられていない場合に...
...]
ary = db["root"] = [1,2,3,4]
ary[0] = [1,1.5]
end

db.transaction(true) do |pstore|
pstore.fetch("root") # => [[1, 1.5], 2, 3, 4]
pstore.fetch("root", 'aaa') # => [[1, 1.5], 2, 3, 4]
pstore.fetch("not_root") # => 例外発生
end

@see Hash#fetch, PStore#[]...

Array#fetch_values(*indexes) -> Array (6139.0)

引数で指定されたインデックスに対する値の配列を返します。

...ます。

@raise IndexError ブロックが与えられてない時に、範囲外のインデックスを引数で指定すると発生します。

//emlist[例][ruby]{
ary = ["a", "b", "c"]

ary.fetch_values(0, 2) # => ["a", "c"]
ary.fetch_values(-1, 1) # => ["d", "b"]
ary.fetch_values(0, 10) #...
...=> index 10 outside of array bounds: -3...3 (IndexError)
ary.fetch_values(0, 10) { |i| i.to_s } # => ["a", "10"]
//}

@see Array#values_at, Array#fetch...

Array#fetch_values(*indexes) { |index| ... } -> Array (6139.0)

引数で指定されたインデックスに対する値の配列を返します。

...ます。

@raise IndexError ブロックが与えられてない時に、範囲外のインデックスを引数で指定すると発生します。

//emlist[例][ruby]{
ary = ["a", "b", "c"]

ary.fetch_values(0, 2) # => ["a", "c"]
ary.fetch_values(-1, 1) # => ["d", "b"]
ary.fetch_values(0, 10) #...
...=> index 10 outside of array bounds: -3...3 (IndexError)
ary.fetch_values(0, 10) { |i| i.to_s } # => ["a", "10"]
//}

@see Array#values_at, Array#fetch...

Hash#fetch_values(key, ...) -> [object] (6133.0)

引数で指定されたキーに関連づけられた値の配列を返します。

...ます。

@raise KeyError ブロックが与えられてない時にキーの探索に失敗すると発生します。

//emlist[例][ruby]{
h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" }

h.fetch_values("cow", "cat") # => ["bovine", "feline"]
h.fetch_values("cow...
...", "bird") # raises KeyError
h.fetch_values("cow", "bird") { |k| k.upcase } # => ["bovine", "BIRD"]
//}

@see Hash#values_at, Hash#fetch...

Hash#fetch_values(key, ...) { |key| ... } -> [object] (6133.0)

引数で指定されたキーに関連づけられた値の配列を返します。

...ます。

@raise KeyError ブロックが与えられてない時にキーの探索に失敗すると発生します。

//emlist[例][ruby]{
h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" }

h.fetch_values("cow", "cat") # => ["bovine", "feline"]
h.fetch_values("cow...
...", "bird") # raises KeyError
h.fetch_values("cow", "bird") { |k| k.upcase } # => ["bovine", "BIRD"]
//}

@see Hash#values_at, Hash#fetch...

絞り込み条件を変える

Gem::RemoteFetcher#download(spec, source_uri, install_dir = Gem.dir) -> String (3007.0)

source_uri から取得した Gem パッケージをキャッシュディレクトリに配置します。

...スを指定します。

@param source_uri 取得先の URI を指定します。

@param install_dir ダウンロードしたファイルの配置先を指定します。

@return ローカルにコピーした Gem ファイルのパスを返します。

@raise Gem::RemoteFetcher::FetchError...

Gem::RemoteFetcher#open_uri_or_path(uri, last_modified = nil, head = false, depth = 0) -> StringIO | File (3007.0)

@param uri URI を指定します。

...ad 真を指定するとヘッダ情報のみ取得します。

@param depth 現在のリダイレクト回数を指定します。

@raise Gem::RemoteFetcher::FetchError デフォルトでは 11 回リダイレクトした場合に発生します。
depth を指定すると 10 - depth 回...
<< < 1 2 3 > >>