るりまサーチ

最速Rubyリファレンスマニュアル検索!
33件ヒット [1-33件を表示] (0.029秒)
トップページ > クエリ:==[x] > クエリ:key[x] > クエリ:each_key[x]

別のキーワード

  1. openssl public_key
  2. _builtin each_key
  3. openssl public_key=
  4. socket pf_key
  5. dbm key

ライブラリ

オブジェクト

検索結果

ENV.each_key {|key| ... } -> self (24369.0)

key を引数としてブロックを評価します。

...key を引数としてブロックを評価します。

//emlist[][ruby]{
ENV['FOO'] = 'bar'
ENV.each_key do |key|
p "key #{key} detected" if key == 'FOO'
end
# "key FOO detected"
//}...

ENV.each_key -> Enumerator (24269.0)

key を引数としてブロックを評価します。

...key を引数としてブロックを評価します。

//emlist[][ruby]{
ENV['FOO'] = 'bar'
ENV.each_key do |key|
p "key #{key} detected" if key == 'FOO'
end
# "key FOO detected"
//}...

tsort (24.0)

tsort はトポロジカルソートと強連結成分に関するモジュールを提供します。

...はトポロジカルソートと強連結成分に関するモジュールを提供します。

==
= Example

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

{1=>[2, 3], 2=>[3...
...], 3=>[], 4=>[]}.tsort
#=> [3, 2, 1, 4]

{1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}.strongly_connected_components
#=> [[4], [2, 3], [1]]
//}

==
= より現実的な例

非常に単純な `make' に似たツールは以下のように実装できます。

//emlist[][ruby]{
require 'tsort'

class Make
def...
...mponent_from(target) {|ns|
if ns.length != 1
fs = ns.delete_if {|n| Array === n}
raise TSort::Cyclic.new("cyclic dependencies: #{fs.join ', '}")
end
n = ns.first
if Array === n
outputs, inputs, block = n
inputs_time = inputs.map {|f| File.mtime...