るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

クラス

キーワード

検索結果

<< 1 2 > >>

Thread#run -> self (26108.0)

停止状態(stop)のスレッドを再開させます。 Thread#wakeup と異なりすぐにスレッドの切り替え を行います。

...

@raise ThreadError 死んでいるスレッドに対して実行すると発生します。

//emlist[例][ruby]{
a = Thread.new { puts "a"; Thread.stop; puts "c" }
sleep 0.1 while a.status!='sleep'
puts "Got here"
a.run
a.join
# => a
# => Got here
# => c
//}

@see Thread#wakeup, Thread.stop...

File#truncate(length) -> 0 (14101.0)

ファイルのサイズを最大 length バイトにします。

...書き込み用にオープンされていなければ発生します。

@raise Errno::EXXX サイズの変更に失敗した場合に発生します。

//emlist[例][ruby]{
IO.write("testfile", "1234567890")
File.open("testfile", "a") do |f|
f.truncate(5) # => 0
f.size # => 5
end
//}...

Integer#truncate(ndigits = 0) -> Integer (14101.0)

0 から self までの整数で、自身にもっとも近い整数を返します。

...します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。

//emlist[][ruby]{
1.truncate # => 1
1.truncate(2) # => 1
18.truncate(-1) # => 10
(-18).truncate(-1) # => -10
//}

@see Numeric#truncate...

Integer#truncate(ndigits = 0) -> Integer | Float (14101.0)

0 から self までの整数で、自身にもっとも近い整数を返します。

...定した場合、Integer を返します。
小数点位置から左に少なくとも n 個の 0 が並びます。

//emlist[][ruby]{
1.truncate # => 1
1.truncate(2) # => 1.0
18.truncate(-1) # => 10
(-18).truncate(-1) # => -10
//}

@see Numeric#truncate...

Numeric#truncate -> Integer (14101.0)

0 から 自身までの整数で、自身にもっとも近い整数を返します。

...0 から 自身までの整数で、自身にもっとも近い整数を返します。

//emlist[例][ruby]{
1.truncate #=> 1
1.2.truncate #=> 1
(-1.2).truncate #=> -1
(-1.5).truncate #=> -1
//}

@see Numeric#ceil, Numeric#floor, Numeric#round...

絞り込み条件を変える

Float#truncate -> Integer (11101.0)

小数点以下を切り捨てて値を整数に変換します。

...小数点以下を切り捨てて値を整数に変換します。


//emlist[例][ruby]{
2.8.truncate # => 2
(-2.8).truncate # => -2
//}

@see Numeric#round, Numeric#ceil, Numeric#floor...

Float#truncate(ndigits = 0) -> Integer | Float (11101.0)

小数点以下を切り捨てて値を整数に変換します。

...す。
小数点位置から左に少なくとも n 個の 0 が並びます。

//emlist[例][ruby]{
2.8.truncate # => 2
(-2.8).truncate # => -2
1.234567.truncate(2) # => 1.23
34567.89.truncate(-2) # => 34500
//}

@see Numeric#round, Numeric#ceil, Numeric#floor...

Rational#truncate(precision = 0) -> Rational | Integer (11101.0)

小数点以下を切り捨てて値を整数に変換します。

...Rational を返します。

//emlist[例][ruby]{
Rational('-123.456').truncate(+1) # => (-617/5)
Rational('-123.456').truncate(+1).to_f # => -123.4
Rational('-123.456').truncate(0) # => -123
Rational('-123.456').truncate(-1) # => -120
//}

@see Rational#ceil, Rational#floor...

ThreadGroup#add(thread) -> self (8025.0)

スレッド thread が属するグループを自身に変更します。

...9168 run>]

tg = ThreadGroup.new
t1 = Thread.new { sleep }
t2 = Thread.new { sleep }
puts "t1 is #{t1}" # => t1 is #<Thread:0x50bef60>
puts "t2 is #{t2}" # => t2 is #<Thread:0x50beed0>
tg.add(t1)
puts "Initial group now #{ThreadGroup::Default.list}"
# => Initial group now [#<Thread:0x3039168 run>, #...
...<Thread:0x50beed0 run>]
puts "tg group now #{tg.list}"
# => tg group now [#<Thread:0x50bef60 run>]
//}...

Thread#status -> String | false | nil (8023.0)

生きているスレッドの状態を文字列 "run"、"sleep", "aborting" のいず れかで返します。正常終了したスレッドに対して false、例外によ り終了したスレッドに対して nil を返します。

...生きているスレッドの状態を文字列 "run"、"sleep", "aborting" のいず
れかで返します。正常終了したスレッドに対して false、例外によ
り終了したスレッドに対して nil を返します。

Thread#alive? が真を返すなら、このメソッドも...
...hread.new { sleep }
d.kill #=> #<Thread:0x401b3678 aborting>
a.status #=> nil
b.status #=> "sleep"
c.status #=> false
d.status #=> "aborting"
Thread.current.status #=> "run"

@see Thread#alive?, Thread#stop?...

絞り込み条件を変える

Thread#wakeup -> self (8023.0)

停止状態(stop)のスレッドを実行可能状態(run)にします。

...を実行可能状態(run)にします。

@raise ThreadError 死んでいるスレッドに対して実行すると発生します。

//emlist[例][ruby]{
c = Thread.new { Thread.stop; puts "hey!" }
sleep 0.1 while c.status!='sleep'
c.wakeup
c.join
# => "hey!"
//}

@see Thread#run, Thread.stop...

Thread#report_on_exception -> bool (8019.0)

真の場合、そのスレッドが例外によって終了した時に、その内容を $stderr に報告します。

...//emlist[例][ruby]{
a = Thread.new{ Thread.stop; raise }
a.report_on_exception = true
a.report_on_exception # => true
a.run
# => #<Thread:0x00007fc3f48c7908@(irb):1 run> terminated with exception (report_on_exception is true):
# Traceback (most recent call last):
# (irb):1:in `block in ir...
...b_binding': unhandled exception
# #<Thread:0x00007fc3f48c7908@(irb):1 dead>
b = Thread.new{ Thread.stop; raise }
b.report_on_exception = false
b.run # => #<Thread:0x00007fc3f48aefc0@(irb):4 dead>
//}

@see Thread.report_on_exception...
<< 1 2 > >>