種類
- インスタンスメソッド (6)
- モジュール関数 (2)
- クラス (1)
クラス
- Integer (6)
モジュール
- Process (2)
キーワード
- Numeric (1)
-
clock
_ gettime (1) - downto (2)
- upto (2)
- waitall (1)
検索結果
先頭5件
-
Integer
# times -> Enumerator (117403.0) -
self 回だけ繰り返します。 self が正の整数でない場合は何もしません。
self 回だけ繰り返します。
self が正の整数でない場合は何もしません。
またブロックパラメータには 0 から self - 1 までの数値が渡されます。
//emlist[][ruby]{
3.times { puts "Hello, World!" } # Hello, World! と3行続いて表示される。
0.times { puts "Hello, World!" } # 何も表示されない。
5.times {|n| print n } # 01234 と表示される。
//}
@see Integer#upto, Integer#downto,... -
Integer
# times {|n| . . . } -> self (117403.0) -
self 回だけ繰り返します。 self が正の整数でない場合は何もしません。
self 回だけ繰り返します。
self が正の整数でない場合は何もしません。
またブロックパラメータには 0 から self - 1 までの数値が渡されます。
//emlist[][ruby]{
3.times { puts "Hello, World!" } # Hello, World! と3行続いて表示される。
0.times { puts "Hello, World!" } # 何も表示されない。
5.times {|n| print n } # 01234 と表示される。
//}
@see Integer#upto, Integer#downto,... -
Integer
# upto(max) {|n| . . . } -> Integer (63364.0) -
self から max まで 1 ずつ増やしながら繰り返します。 self > max であれば何もしません。
self から max まで 1 ずつ増やしながら繰り返します。
self > max であれば何もしません。
@param max 数値
@return self を返します。
//emlist[][ruby]{
5.upto(10) {|i| print i, " " } # => 5 6 7 8 9 10
//}
@see Integer#downto, Numeric#step, Integer#times -
Integer
# upto(max) -> Enumerator (63064.0) -
self から max まで 1 ずつ増やしながら繰り返します。 self > max であれば何もしません。
self から max まで 1 ずつ増やしながら繰り返します。
self > max であれば何もしません。
@param max 数値
@return self を返します。
//emlist[][ruby]{
5.upto(10) {|i| print i, " " } # => 5 6 7 8 9 10
//}
@see Integer#downto, Numeric#step, Integer#times -
Integer
# downto(min) -> Enumerator (63061.0) -
self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。
self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。
self < min であれば何もしません。
@param min 数値
@return self を返します。
//emlist[][ruby]{
5.downto(1) {|i| print i, " " } # => 5 4 3 2 1
//}
@see Integer#upto, Numeric#step, Integer#times -
Integer
# downto(min) {|n| . . . } -> self (63061.0) -
self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。
self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。
self < min であれば何もしません。
@param min 数値
@return self を返します。
//emlist[][ruby]{
5.downto(1) {|i| print i, " " } # => 5 4 3 2 1
//}
@see Integer#upto, Numeric#step, Integer#times -
Process
. # clock _ gettime(clock _ id , unit=:float _ second) -> Float | Integer (472.0) -
POSIX の clock_gettime() 関数の時間を返します。
POSIX の clock_gettime() 関数の時間を返します。
例:
p Process.clock_gettime(Process::CLOCK_MONOTONIC) #=> 896053.968060096
@param clock_id クロックの種類を以下の定数のいずれかで指定します。
サポートされている定数は OS やバージョンに依存します。
: Process::CLOCK_REALTIME
SUSv2 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 2.1, macOS... -
Process
. # waitall -> [[Integer , Process :: Status]] (328.0) -
全ての子プロセスが終了するのを待ちます。 終了した子プロセスの pid と終了ステータス (Process::Status) の配列の配列を返します。 子プロセスがいない状態でこのメソッドを呼び出すと空の配列を返します。
全ての子プロセスが終了するのを待ちます。
終了した子プロセスの pid と終了ステータス
(Process::Status) の配列の配列を返します。
子プロセスがいない状態でこのメソッドを呼び出すと空の配列を返します。
$? には最後に終了した子プロセスの Process::Status オブジェクトが設定されます。
2.times {|n|
Process.fork() { exit n }
}
p Process.waitall
#=> :Status: pid=2766,exited(1)>], [2765, #<Process::St... -
Numeric (253.0)
-
数値を表す抽象クラスです。Integer や Float などの数値クラス は Numeric のサブクラスとして実装されています。
数値を表す抽象クラスです。Integer や Float などの数値クラス
は Numeric のサブクラスとして実装されています。
演算や比較を行うメソッド(+, -, *, /, <=>)は Numeric のサブクラスで定義されま
す。Numeric で定義されているメソッドは、サブクラスで提供されているメソッド
(+, -, *, /, %) を利用して定義されるものがほとんどです。
つまり Numeric で定義されているメソッドは、Numeric のサブクラスとして新たに数値クラスを定義した時に、
演算メソッド(+, -, *, /, %, <=>, coerce)だけを定義すれ...