るりまサーチ

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

別のキーワード

  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 (18200.0)

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

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

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

uri = URI.parse('http://www.example...
...uest_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 を指定][ruby]{
require 'n...
...: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 (18200.0)

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

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

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

uri = URI.parse('http://www.example...
...uest_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 を指定][ruby]{
require 'n...
...: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 (18200.0)

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

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

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

uri = URI.parse('http://www.example...
...uest_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 を指定][ruby]{
require 'n...
...: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 } # =>...

Array#fetch(nth) -> object (18152.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 #...

Array#fetch(nth) {|nth| ... } -> object (18152.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 #...

絞り込み条件を変える

Array#fetch(nth, ifnone) -> object (18152.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 #...

TSort#tsort -> Array (37.0)

頂点をトポロジカルソートして得られる配列を返します。 この配列は子から親に向かってソートされています。 すなわち、最初の要素は子を持たず、最後の要素は親を持ちません。

...を持ちません。

@raise TSort::Cyclic 閉路が存在するとき、発生します。

//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


sorted = {1=>[2, 3], 2=>[...

TSort#tsort_each -> Enumerator (37.0)

TSort#tsort メソッドのイテレータ版です。 obj.tsort_each は obj.tsort.each と似ていますが、 ブロックの評価中に obj が変更された場合は予期しない結果になる ことがあります。

...ic を起こします。

@raise TSort::Cyclic 閉路が存在するとき、発生します.

//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, 3], 2...

TSort#tsort_each {|node| ...} -> nil (37.0)

TSort#tsort メソッドのイテレータ版です。 obj.tsort_each は obj.tsort.each と似ていますが、 ブロックの評価中に obj が変更された場合は予期しない結果になる ことがあります。

...ic を起こします。

@raise TSort::Cyclic 閉路が存在するとき、発生します.

//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, 3], 2...
<< 1 2 > >>