るりまサーチ

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

別のキーワード

  1. openssl t61string
  2. asn1 t61string
  3. t61string new
  4. matrix t
  5. fiddle sizeof_size_t

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 > >>

Pathname#join(*args) -> Pathname (21220.0)

与えられたパス名を連結します。

...ます。

@
param args 連結したいディレクトリ名やファイル名を文字列で与えます。

//emlist[例][ruby]{
require
"pathname"

path0 = Pathname("/usr") # Pathname:/usr
path0 = path0.join("bin/ruby") # Pathname:/usr/bin/ruby
# 上記の path0 の処...
...理は下記の path1 と同様のパスになります
path1 = Pathname("/usr") + "bin/ruby" # Pathname:/usr/bin/ruby
path0 == path1 #=> true
//}...

ThreadsWait#join(*threads) -> () (21220.0)

終了を待つスレッドの対象として、threads で指定されたスレッドを指定します。

...threads で指定されたスレッドを指定します。

@
param threads 複数スレッドの終了を待つスレッドに指定されたthreadsを加えます。

require
'thwait'

t
hreads = []
5.times {|i|
t
hreads << Thread.new { sleep 1; p Thread.current }
}

t
hall = Threads...
...Wait.new
p thall.threads #=> []
t
hall.join(*threads)
p thall.threads
#=> [#<Thread:0x216ec dead>, #<Thread:0x21660 dead>, #<Thread:0x215d4 dead>, #<Thread:0x214bc dead>]...

Set#disjoint?(set) -> bool (12225.0)

self と set が互いに素な集合である場合に true を返します。

...self と set が互いに素な集合である場合に true を返します。

逆に self と set の共通集合かを確認する場合には Set#intersect? を
使用します。

@
param self Set オブジェクトを指定します。
@
raise ArgumentError 引数が Set オブジェクトで...
...ない場合に発生します。

//emlist[][ruby]{
require
'set'
p Set[1, 2, 3].disjoint? Set[3, 4] # => false
p Set[1, 2, 3].disjoint? Set[4, 5] # => true
//}

@
see Set#intersect?...

ThreadsWait#join_nowait(*threads) -> () (12220.0)

終了を待つスレッドの対象として、threads で指定されたスレッドを指定します。 しかし、実際には終了をまちません。

...て、threads で指定されたスレッドを指定します。
しかし、実際には終了をまちません。

@
param threads 複数スレッドの終了を待つスレッドに指定されたthreadsを加えます。

require
'thwait'

t
hreads = []
5.times {|i|
t
hreads << Thread.n...
...ew { sleep 1; p Thread.current }
}

t
hall = ThreadsWait.new
p thall.threads #=> []
t
hall.join_nowait(*threads)
p thall.threads #=> [#<Thread:0x21638 sleep>, #<Thread:0x215ac sleep>, #<Thread:0x21520 sleep>, #<Thread:0x21494 sleep>, #<Thread:0x21408 sleep>]
# 実際には終了を待っ...

OptionParser#on_tail(*arg, &block) -> self (6137.0)

オプションを取り扱うためのブロックを自身の持つリストの最後に登録します。

...

@
param arg OptionParser#on と同様です。

@
param block OptionParser#on と同様です。

//emlist[例][ruby]{
require
"optparse"

opts = OptionParser.new do |opts|
opts.on_head("-i", "--init")
opts.on("-u", "--update")
opts.on_tail("-h", "--help")
end

puts opts.help

# => Usage: test...
...[options]
# -i, --init
# -u, --update
# -h, --help
//}

//emlist[例][ruby]{
require
"optparse"

opts = OptionParser.new
opts.on_tail("-h", "--help", "Show this message") do
puts opts
exit
end

opts.on_tail("--version", "Show version") do
puts OptionParser::Version.join('.')
exit
en...
...d
//}

@
see OptionParser#on, OptionParser#on_head...

絞り込み条件を変える

Thread::SizedQueue#shift(non_block = false) -> object (6137.0)

キューからひとつ値を取り出します。 キューに push しようと待っているスレッドがあれば、実行を再開させます。

...ば、実行を再開させます。

@
param non_block true を与えると、キューが空の時に例外 ThreadError が発生します。

//emlist[例][ruby]{
require
'thread'

q = SizedQueue.new(4)

t
h1 = Thread.start do
while resource = q.pop
puts resource
end
end

[:resource1, :reso...
...r)
}

t
h1.join
# => resource1
# resource2
# resource3
//}

//emlist[例: nonblock = true][ruby]{
require
'thread'

q = SizedQueue.new(4)

t
h1 = Thread.start do
while resource = q.pop
puts resource
end
end

[:resource1, :resource2, :resource3, nil].each{|r|
q.push(r)
}

begin
t
h1.join
q...
....pop(true)
rescue => e
p e
p e.message
end

# => resource1
# resource2
# resource3
# => #<ThreadError: queue empty>
# => "queue empty"
//}

@
see Thread::Queue#pop...

ThreadsWait#next_wait(nonblock = nil) -> Thread (6137.0)

指定したスレッドのどれかが終了するまで待ちます。

...で待ちます。

@
param nonblock true を与えると、キューが空の時、例外 ThreadsWait::ErrNoFinishedThread が発生します。

@
raise ErrNoWaitingThread 終了をまつスレッドが存在しない時、発生します。

@
raise ErrNoFinishedThread nonblock がtrue でかつ、...
...キューが空の時、発生します。

#使用例
require
'thwait'

t
hreads = []
2.times {|i|
t
hreads << Thread.new { sleep i }
}

t
hall = ThreadsWait.new
t
hall.join_nowait(*threads)
until thall.empty?
t
h = thall.next_wait
p th
end

@
see Queue#pop...

Zlib::Deflate#set_dictionary(string) -> String (6137.0)

圧縮に用いる辞書を指定します。string を返します。 このメソッドは Zlib::Deflate.new, Zlib::ZStream#reset を呼び出した直後にのみ有効です。詳細は zlib.h を参照して下さい。

...string を返します。
このメソッドは Zlib::Deflate.new, Zlib::ZStream#reset
を呼び出した直後にのみ有効です。詳細は zlib.h を参照して下さい。

@
param string 辞書に用いる文字列を指定します。詳しくは zlib.h を参照してください。
@
retur...
...します。

require
'zlib'

def case1(str)
dez = Zlib::Deflate.new
comp_str = dez.deflate(str)
comp_str << dez.finish
comp_str.size
end

def case2(str, dict)
dez = Zlib::Deflate.new
p dez.set_dictionary(dict)
comp_str = dez.deflate(str)
comp_str << dez.fin...
...omp_str.size
end

i = 10
dict = 'hoge_fuga_ugougo'
sset = [ dict, 'taeagbamike', 'ugotagma', 'fugebogya' ]
g = [ 0, 1, 1, 1, 0, 0, 0, 3, 3, 3, 0, 0, 1, 1, 0, 0, 0, 1, 2, 2, 0, 0, 0, 2, 0, 1, 1, 0, 0, 0, 0, 0]
str = (1..i).collect{|m| t = rand(g.size); sset.at(g[t])}.join("")

printf "%...

Thread::Queue#shift(non_block = false) -> object (6131.0)

キューからひとつ値を取り出します。キューが空の時、呼出元のスレッドは停止します。

...出元のスレッドは停止します。

@
param non_block true を与えると、キューが空の時に例外 ThreadError が発生します。

//emlist[例][ruby]{
require
'thread'

q = Queue.new

t
h1 = Thread.start do
while resource = q.pop
puts resource
end
end

[:resource1, :resour...
...ch { |r|
q.push(r)
}

t
h1.join
//}

//emlist[例: nonblock = true][ruby]{
require
'thread'

q = Queue.new

t
h1 = Thread.start do
while resource = q.pop
puts resource
end
end

[:resource1, :resource2, :resource3, nil].each { |r|
q.push(r)
}

begin
t
h1.join
q.pop(true)
rescue => e
p...
...e
end

# => resource1
# resource2
# resource3
# => #<ThreadError: queue empty>
# => "queue empty"
//}...

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

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

...ん。

each_strongly_connected_component_from は
t
sort_each_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], 2=>[3, 4], 3=>[2], 4=>[]}

non_sort.each_strongly_connected_component{|nodes|
p nodes
nodes.each {|node|
non_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| ...} -> () (6125.0)

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

...ん。

each_strongly_connected_component_from は
t
sort_each_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], 2=>[3, 4], 3=>[2], 4=>[]}

non_sort.each_strongly_connected_component{|nodes|
p nodes
nodes.each {|node|
non_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 3 > >>