るりまサーチ

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

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

クラス

モジュール

検索結果

<< 1 2 > >>

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

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

...返します。
key は大文字小文字を区別しません。

@
param key ヘッダフィール名を文字列で与えます。
@
param default 該当するキーが登録されていない時の返り値を指定します。
@
raise IndexError 引数defaultもブロックも与えられてない...
...y が存在する][ruby]{
require 'net/http'

uri = URI.parse('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")...
...ent-length">
end

//}

//emlist[例 key , default を指定][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", "default") # => "default"
//}

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

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

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

...返します。
key は大文字小文字を区別しません。

@
param key ヘッダフィール名を文字列で与えます。
@
param default 該当するキーが登録されていない時の返り値を指定します。
@
raise IndexError 引数defaultもブロックも与えられてない...
...y が存在する][ruby]{
require 'net/http'

uri = URI.parse('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")...
...ent-length">
end

//}

//emlist[例 key , default を指定][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", "default") # => "default"
//}

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

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

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

...返します。
key は大文字小文字を区別しません。

@
param key ヘッダフィール名を文字列で与えます。
@
param default 該当するキーが登録されていない時の返り値を指定します。
@
raise IndexError 引数defaultもブロックも与えられてない...
...y が存在する][ruby]{
require 'net/http'

uri = URI.parse('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")...
...ent-length">
end

//}

//emlist[例 key , default を指定][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", "default") # => "default"
//}

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

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

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

...価した結果を返します。

@
param nth 取得したい要素のインデックスを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる
暗黙の型変換を試みます。

@
param ifnone 要素が存在し...
...なかった場合に返すべき値を指定します。

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

@
raise 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 #...

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

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

...価した結果を返します。

@
param nth 取得したい要素のインデックスを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる
暗黙の型変換を試みます。

@
param ifnone 要素が存在し...
...なかった場合に返すべき値を指定します。

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

@
raise 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 #...

絞り込み条件を変える

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

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

...価した結果を返します。

@
param nth 取得したい要素のインデックスを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる
暗黙の型変換を試みます。

@
param ifnone 要素が存在し...
...なかった場合に返すべき値を指定します。

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

@
raise 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 #...

Thread#[](name) -> object | nil (55.0)

name に対応したスレッドに固有のデータを取り出します。 name に対応するスレッド固有データがなければ nil を返し ます。

...す。
name に対応するスレッド固有データがなければ nil を返し
ます。

@
param name スレッド固有データのキーを文字列か Symbol で指定します。

//emlist[例][ruby]{
[
Thread.new { Thread.current["name"] = "A" },
Thread.new { Thread.current[:name] = "...
...B" },
Thread.new { Thread.current["name"] = "C" }
].each do |th|
th.join
puts "#{th.inspect}: #{th[:name]}"
end


# => #<Thread:0x00000002a54220 dead>: A
# => #<Thread:0x00000002a541a8 dead>: B
# => #<Thread:0x00000002a54130 dead>: C
//}

Thread#[] と Thread#[]= を用いたスレッド固有...
...] = newvalue
yield
ensure
Thread.current[:name] = oldvalue
end

end

//}

この関数に与えるブロックがFiberを切り替える場合は動的スコープとしては
正しく動作しません。

//emlist[][ruby]{
f = Fiber.new {
meth(1) {
Fiber.yield
}
}
meth(2) {
f....

TSort#each_strongly_connected_component_from(node, id_map={}, stack=[]) -> Enumerator (37.0)

node から到達可能な強連結成分についてのイテレータです。

...を呼びません。

@
param node ノードを指定します。

//emlist[例 到達可能なノードを表示する][ruby]{
require 'tsort'

class Hash
include TSort
alias tsort_each_node each_key
def tsort_each_child(node, &block)
fetch
(node).each(&block)
end

end


non_sort = {1=>[2]...
...sort.each_strongly_connected_component_from(node){|ns|
printf("%s -> %s\n", node, ns.join(","))
}
}
}

#出力
#=> [4]
#=> 4 -> 4
#=> [2, 3]
#=> 2 -> 4
#=> 2 -> 2,3
#=> 3 -> 4
#=> 3 -> 3,2
#=> [1]
#=> 1 -> 4
#=> 1 -> 2,3
#=> 1 -> 1
//}

@
see TSort.each_strongly_connected_component_from...

TSort#each_strongly_connected_component_from(node, id_map={}, stack=[]) {|nodes| ...} -> () (37.0)

node から到達可能な強連結成分についてのイテレータです。

...を呼びません。

@
param node ノードを指定します。

//emlist[例 到達可能なノードを表示する][ruby]{
require 'tsort'

class Hash
include TSort
alias tsort_each_node each_key
def tsort_each_child(node, &block)
fetch
(node).each(&block)
end

end


non_sort = {1=>[2]...
...sort.each_strongly_connected_component_from(node){|ns|
printf("%s -> %s\n", node, ns.join(","))
}
}
}

#出力
#=> [4]
#=> 4 -> 4
#=> [2, 3]
#=> 2 -> 4
#=> 2 -> 2,3
#=> 3 -> 4
#=> 3 -> 3,2
#=> [1]
#=> 1 -> 4
#=> 1 -> 2,3
#=> 1 -> 1
//}

@
see TSort.each_strongly_connected_component_from...
<< 1 2 > >>