種類
- モジュール関数 (22)
- インスタンスメソッド (8)
- 変数 (7)
ライブラリ
- English (4)
- ビルトイン (23)
- bigdecimal (2)
- mkmf (8)
キーワード
-
$ $ (1) -
$ INPUT _ LINE _ NUMBER (1) -
$ NR (1) -
$ PID (1) -
$ PROCESS _ ID (1) -
$ SAFE (1) - BigDecimal (2)
- Integer (1)
- Rational (1)
-
check
_ signedness (2) -
check
_ sizeof (2) -
convertible
_ int (2) - fork (2)
- format (1)
- putc (1)
- rand (2)
- sleep (2)
- spawn (4)
- sprintf (1)
- syscall (1)
- test (2)
-
try
_ constant (2)
検索結果
先頭5件
-
Kernel
. # Integer(arg , base = 0) -> Integer (118078.0) -
引数を整数 (Fixnum,Bignum) に変換した結果を返します。
引数を整数
(Fixnum,Bignum)
に変換した結果を返します。
引数が数値の場合は直接変換し(小数点以下切り落とし)、
文字列の場合は、進数を表す接頭辞を含む整数表現とみなせる文字列のみ
変換します。
数値と文字列以外のオブジェクトに対しては arg.to_int, arg.to_i を
この順に使用して変換します。
@param arg 変換対象のオブジェクトです。
@param base 基数として0か2から36の整数を指定します(引数argに文字列を指
定した場合のみ)。省略するか0を指定した場合はプリフィクスか
ら基数を... -
Kernel
. # srand -> Integer (63394.0) -
Kernel.#rand や Random.rand で使用される擬似乱数生成器の種を設定し、古い種を返します。
...
Kernel.#rand や Random.rand で使用される擬似乱数生成器の種を設定し、古い種を返します。
seed に整数を指定するとその絶対値を乱数の種に設定します。
それ以外の値を指定した場合は seed.to_int が指定されたものとして扱いま......す。
seed に既知の値を与えると、以前の Kernel.#rand の値を再現できます。
seed が省略された時には
現在の時刻やプロセス ID、srand を呼び出した回数、
また可能なら /dev/urandom から読み出したデータなどを元に種を作ります......) #=> 0.938911141393347
p rand(0) #=> 0.915824970865251
seeds << srand(num)
p rand(6) #=> 3
p rand(6) #=> 0
p rand(0) #=> 0.445804380918972
p rand(0) #=> 0.422248634121701
seeds << srand
p seeds #=> [455675, 2995620310703489221660585195204777696, 455675]
//}
@see Kernel.#rand, Random::DEFAULT... -
Kernel
. # srand(seed) -> Integer (63394.0) -
Kernel.#rand や Random.rand で使用される擬似乱数生成器の種を設定し、古い種を返します。
...
Kernel.#rand や Random.rand で使用される擬似乱数生成器の種を設定し、古い種を返します。
seed に整数を指定するとその絶対値を乱数の種に設定します。
それ以外の値を指定した場合は seed.to_int が指定されたものとして扱いま......す。
seed に既知の値を与えると、以前の Kernel.#rand の値を再現できます。
seed が省略された時には
現在の時刻やプロセス ID、srand を呼び出した回数、
また可能なら /dev/urandom から読み出したデータなどを元に種を作ります......) #=> 0.938911141393347
p rand(0) #=> 0.915824970865251
seeds << srand(num)
p rand(6) #=> 3
p rand(6) #=> 0
p rand(0) #=> 0.445804380918972
p rand(0) #=> 0.422248634121701
seeds << srand
p seeds #=> [455675, 2995620310703489221660585195204777696, 455675]
//}
@see Kernel.#rand, Random::DEFAULT... -
Kernel
# try _ constant(const , headers = nil , opt = "") -> Integer | nil (63358.0) -
定数 const がシステムに存在するかどうか検査します。 Kernel#have_const を使ってください。
...定数 const がシステムに存在するかどうか検査します。
Kernel#have_const を使ってください。
@param const C 言語の定数名を指定します。
@param headers 追加のヘッダファイルを指定します。
@param opt コンパイラに渡すオプションを... -
Kernel
# try _ constant(const , headers = nil , opt = "") { . . . } -> Integer | nil (63358.0) -
定数 const がシステムに存在するかどうか検査します。 Kernel#have_const を使ってください。
...定数 const がシステムに存在するかどうか検査します。
Kernel#have_const を使ってください。
@param const C 言語の定数名を指定します。
@param headers 追加のヘッダファイルを指定します。
@param opt コンパイラに渡すオプションを... -
Kernel
. # spawn(command , options={}) -> Integer (63358.0) -
引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
...表す Hash
@param options オプションパラメータ Hash
@raise Errno::EXXX 起動に失敗し、ruby インタプリタに制御が戻った場合に発生します。
@raise Errno::EXXX コマンドが実行できなかった場合に発生します。
@see Kernel.#system,Kernel.#exec... -
Kernel
. # spawn(env , command , options={}) -> Integer (63358.0) -
引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
...表す Hash
@param options オプションパラメータ Hash
@raise Errno::EXXX 起動に失敗し、ruby インタプリタに制御が戻った場合に発生します。
@raise Errno::EXXX コマンドが実行できなかった場合に発生します。
@see Kernel.#system,Kernel.#exec... -
Kernel
. # spawn(env , program , *args , options={}) -> Integer (63358.0) -
引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
...列を指定します。
@param options オプションパラメータ Hash
@raise ArgumentError 第一引数が配列かつ要素数が 2 でない場合に発生します。
@raise Errno::EXXX コマンドが実行できなかった場合に発生します。
@see Kernel.#system,Kernel.#exec... -
Kernel
. # spawn(program , *args) -> Integer (63358.0) -
引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
...列を指定します。
@param options オプションパラメータ Hash
@raise ArgumentError 第一引数が配列かつ要素数が 2 でない場合に発生します。
@raise Errno::EXXX コマンドが実行できなかった場合に発生します。
@see Kernel.#system,Kernel.#exec... -
Kernel
. # fork -> Integer | nil (63346.0) -
fork(2) システムコールを使ってプロセスの複製を作 ります。親プロセスでは子プロセスのプロセスIDを、子プロセスでは nil を返します。ブロックを指定して呼び出した場合には、生成し た子プロセスでブロックを評価します。
...puts "parent process. pid: #{Process.pid}, child pid: #{child_pid}"
# => parent process. pid: 79055, child pid: 79602
# 親プロセスでの処理
# ...
# 子プロセスの終了を待って終了。
Process.waitpid(child_pid)
//}
@see IO.popen,IO.pipe,Kernel.#at_exit,Kernel.#exit!, fork(2)... -
Kernel
. # fork { . . . } -> Integer | nil (63346.0) -
fork(2) システムコールを使ってプロセスの複製を作 ります。親プロセスでは子プロセスのプロセスIDを、子プロセスでは nil を返します。ブロックを指定して呼び出した場合には、生成し た子プロセスでブロックを評価します。
...puts "parent process. pid: #{Process.pid}, child pid: #{child_pid}"
# => parent process. pid: 79055, child pid: 79602
# 親プロセスでの処理
# ...
# 子プロセスの終了を待って終了。
Process.waitpid(child_pid)
//}
@see IO.popen,IO.pipe,Kernel.#at_exit,Kernel.#exit!, fork(2)... -
Kernel
. # rand(max = 0) -> Integer | Float (63346.0) -
擬似乱数を発生させます。
...を、少なくとも片方が実数の場合は実数を返します。
range に含まれる数が無い場合は nil を返します。
まだ Kernel.#srand が呼ばれていなければ自動的に呼び出します。
擬似乱数生成器として Random::DEFAULT を使用します。
こ......10) #=> 1 (0 から 9 までの整数。終端を含まない)
rand(1.0..1.5) #=> 1.1362963047752432 (1.0 以上 1.5 以下の実数)
rand(1.0...1.5) #=> 1.1382321275715483 (1.0 以上 1.5 未満の実数)
rand(1..0) #=> nil
//}
@see Kernel.#srand, Random#rand, Random... -
Kernel
. # rand(range) -> Integer | Float | nil (63346.0) -
擬似乱数を発生させます。
...を、少なくとも片方が実数の場合は実数を返します。
range に含まれる数が無い場合は nil を返します。
まだ Kernel.#srand が呼ばれていなければ自動的に呼び出します。
擬似乱数生成器として Random::DEFAULT を使用します。
こ......10) #=> 1 (0 から 9 までの整数。終端を含まない)
rand(1.0..1.5) #=> 1.1362963047752432 (1.0 以上 1.5 以下の実数)
rand(1.0...1.5) #=> 1.1382321275715483 (1.0 以上 1.5 未満の実数)
rand(1..0) #=> nil
//}
@see Kernel.#srand, Random#rand, Random... -
Kernel
. # test(cmd , file) -> bool | Time | Integer | nil (63325.0) -
単体のファイルでファイルテストを行います。
単体のファイルでファイルテストを行います。
@param cmd 以下に示す文字リテラル、文字列、あるいは同じ文字を表す数値
です。文字列の場合はその先頭の文字だけをコマンドとみなします。
@param file テストするファイルのパスを表す文字列か IO オブジェクトを指定します。
@return 下表に特に明記していないものは、真偽値を返します。
以下は cmd として指定できる文字リテラルとその意味です。
: ?r
ファイルを実効 uid で読むことができる
: ?w
ファイルに実効 uid で書くことができる
: ?x
ファイルを... -
Kernel
# check _ sizeof(type , headers = nil) -> Integer | nil (63310.0) -
与えられた型のサイズを返します。
与えられた型のサイズを返します。
型 type がシステムに存在する場合は、グローバル変数 $defs に
"-DSIZEOF_type=X" を追加し、型のサイズを返します。型 type がシステムに
存在しない場合は、nil を返します。
例えば、
require 'mkmf'
check_sizeof('mystruct') # => 12
である場合、SIZEOF_MYSTRUCT=12 というプリプロセッサマクロをコンパイラに渡します。
@param type 検査したい型を指定します。
@param headers 追加のヘッダファイルを指定します。 -
Kernel
# check _ sizeof(type , headers = nil) { . . . } -> Integer | nil (63310.0) -
与えられた型のサイズを返します。
与えられた型のサイズを返します。
型 type がシステムに存在する場合は、グローバル変数 $defs に
"-DSIZEOF_type=X" を追加し、型のサイズを返します。型 type がシステムに
存在しない場合は、nil を返します。
例えば、
require 'mkmf'
check_sizeof('mystruct') # => 12
である場合、SIZEOF_MYSTRUCT=12 というプリプロセッサマクロをコンパイラに渡します。
@param type 検査したい型を指定します。
@param headers 追加のヘッダファイルを指定します。 -
Kernel
$ $ INPUT _ LINE _ NUMBER -> Integer (63310.0) -
$. の別名
$. の別名
1 e
2 f
3 g
4 h
5 i
# end of a.txt
require "English"
File.foreach(ARGV.at(0)){|line|
# read line
}
p $INPUT_LINE_NUMBER
# end of sample.rb
ruby sample.rb a.txt
#=> 5 -
Kernel
$ $ NR -> Integer (63310.0) -
$. の別名
$. の別名
1 e
2 f
3 g
4 h
5 i
# end of a.txt
require "English"
File.foreach(ARGV.at(0)){|line|
# read line
}
p $INPUT_LINE_NUMBER
# end of sample.rb
ruby sample.rb a.txt
#=> 5 -
Kernel
$ $ PID -> Integer (63310.0) -
$$ の別名
$$ の別名
require "English"
p sprintf("something%s", $PID) #=> "something5543" など -
Kernel
$ $ PROCESS _ ID -> Integer (63310.0) -
$$ の別名
$$ の別名
require "English"
p sprintf("something%s", $PID) #=> "something5543" など -
Kernel
. # sleep -> Integer (63310.0) -
sec 秒だけプログラムの実行を停止します。
sec 秒だけプログラムの実行を停止します。
sec が省略された場合、他スレッドからの Thread#run
などで明示的に起こさない限り永久にスリープします。Thread#runを呼ぶとその時点で
sleepの実行が中断されます。
@param sec 停止する秒数を非負の数値で指定します。浮動小数点数も指定できます。
省略された場合、永久にスリープします。
@return 実際に停止していた秒数 (整数に丸められた値) です。
//emlist[例][ruby]{
it = Thread.new do
sleep
puts 'it_end'
end... -
Kernel
. # sleep(sec) -> Integer (63310.0) -
sec 秒だけプログラムの実行を停止します。
sec 秒だけプログラムの実行を停止します。
sec が省略された場合、他スレッドからの Thread#run
などで明示的に起こさない限り永久にスリープします。Thread#runを呼ぶとその時点で
sleepの実行が中断されます。
@param sec 停止する秒数を非負の数値で指定します。浮動小数点数も指定できます。
省略された場合、永久にスリープします。
@return 実際に停止していた秒数 (整数に丸められた値) です。
//emlist[例][ruby]{
it = Thread.new do
sleep
puts 'it_end'
end... -
Kernel
$ $ $ -> Integer (63307.0) -
現在実行中の Ruby プロセスのプロセス ID です。 Process.#pid と同じです。
現在実行中の Ruby プロセスのプロセス ID です。
Process.#pid と同じです。
この変数はグローバルスコープです。 -
Kernel
$ $ . -> Integer (63307.0) -
いずれかの IO オブジェクトが最後に読んだ行の行番号です。 Object::ARGF などの IO 互換のオブジェクトも $. を更新します。
いずれかの IO オブジェクトが最後に読んだ行の行番号です。
Object::ARGF などの IO 互換のオブジェクトも $. を更新します。
IO からの読み込みが起きるタイミングが予測不能であるような複雑なプログラムでは使用すべきではありません。特に、マルチスレッドプログラムではスレッド間で競合を起こす可能性があります。
そのような場合には、 IO#lineno を使用してください。
この変数はグローバルスコープです。
Ruby起動時の初期値は 0 です。 -
Kernel
$ $ SAFE -> Integer (63307.0) -
カレントスレッドのセーフレベルを表す整数です。
カレントスレッドのセーフレベルを表す整数です。
セーフレベルについてはspec/safelevel を参照してください。
Thread.current.safe_level と同じです。
非整数を代入しようとすると TypeError が発生します。
この変数はスレッドローカルです。
Ruby起動時の初期値は 0 です。 -
Kernel
. # syscall(num , *arg) -> Integer (63307.0) -
numで指定された番号のシステムコールを実行します。 第2引数以降をシステムコールの引数として渡します。
numで指定された番号のシステムコールを実行します。
第2引数以降をシステムコールの引数として渡します。
どの数値がどのシステムコールに対応するかは、
syscall(2) や
/usr/include/sys/syscall.h を参照してください。
システムコールの慣習に従い、syscall(2)
が -1 を返す場合には例外 Errno::EXXX が発生します。
それ以外では、返した値をそのまま数値で返します。
ライブラリ fiddle を使えばより高レベルな操作ができます。
@param num システムコール番号です。
@param arg 文字列か、整数です。最大 9 ... -
Kernel
# convertible _ int(type , headers = nil , opts = nil) (63148.0) -
Returns the convertible integer type of the given +type+. You may optionally specify additional +headers+ to search in for the +type+. _Convertible_ means actually same type, or typedefed from same type. If the +type+ is a integer type and _convertible_ type is found, following macros are passed as preprocessor constants to the compiler using the +type+ name, in uppercase. * 'TYPEOF_', followed by the +type+ name, followed by '=X' where 'X' is the found _convertible_ type name. * 'TYP2NUM' and 'NUM2TYP, where 'TYP' is the +type+ name in uppercase with replacing '_t' suffix with 'T', followed by '=X' where 'X' is the macro name to convert +type+ to +Integer+ object, and vice versa. For example, if foobar_t is defined as unsigned long, then convertible_int("foobar_t") would return "unsigned long", and define macros: #define TYPEOF_FOOBAR_T unsigned long #define FOOBART2NUM ULONG2NUM #define NUM2FOOBART NUM2ULONG
Returns the convertible integer type of the given +type+. You may
optionally specify additional +headers+ to search in for the +type+.
_Convertible_ means actually same type, or typedefed from same type.
If the +type+ is a integer type and _convertible_ type is found,
following macros are p... -
Kernel
# convertible _ int(type , headers = nil , opts = nil) { . . . } (63148.0) -
Returns the convertible integer type of the given +type+. You may optionally specify additional +headers+ to search in for the +type+. _Convertible_ means actually same type, or typedefed from same type. If the +type+ is a integer type and _convertible_ type is found, following macros are passed as preprocessor constants to the compiler using the +type+ name, in uppercase. * 'TYPEOF_', followed by the +type+ name, followed by '=X' where 'X' is the found _convertible_ type name. * 'TYP2NUM' and 'NUM2TYP, where 'TYP' is the +type+ name in uppercase with replacing '_t' suffix with 'T', followed by '=X' where 'X' is the macro name to convert +type+ to +Integer+ object, and vice versa. For example, if foobar_t is defined as unsigned long, then convertible_int("foobar_t") would return "unsigned long", and define macros: #define TYPEOF_FOOBAR_T unsigned long #define FOOBART2NUM ULONG2NUM #define NUM2FOOBART NUM2ULONG
Returns the convertible integer type of the given +type+. You may
optionally specify additional +headers+ to search in for the +type+.
_Convertible_ means actually same type, or typedefed from same type.
If the +type+ is a integer type and _convertible_ type is found,
following macros are p... -
Kernel
# check _ signedness(type , headers = nil , opts = nil) -> "signed" | "unsigned" | nil (63100.0) -
Returns the signedness of the given +type+. You may optionally specify additional +headers+ to search in for the +type+. If the +type+ is found and is a numeric type, a macro is passed as a preprocessor constant to the compiler using the +type+ name, in uppercase, prepended with 'SIGNEDNESS_OF_', followed by the +type+ name, followed by '=X' where 'X' is positive integer if the +type+ is unsigned, or negative integer if the +type+ is signed. For example, if size_t is defined as unsigned, then check_signedness('size_t') would returned +1 and the SIGNEDNESS_OF_SIZE_T=+1 preprocessor macro would be passed to the compiler, and SIGNEDNESS_OF_INT=-1 if check_signedness('int') is done.
Returns the signedness of the given +type+. You may optionally
specify additional +headers+ to search in for the +type+.
If the +type+ is found and is a numeric type, a macro is passed as a
preprocessor constant to the compiler using the +type+ name, in
uppercase, prepended with 'SIGNEDNESS... -
Kernel
# check _ signedness(type , headers = nil , opts = nil) { . . . } -> "signed" | "unsigned" | nil (63100.0) -
Returns the signedness of the given +type+. You may optionally specify additional +headers+ to search in for the +type+. If the +type+ is found and is a numeric type, a macro is passed as a preprocessor constant to the compiler using the +type+ name, in uppercase, prepended with 'SIGNEDNESS_OF_', followed by the +type+ name, followed by '=X' where 'X' is positive integer if the +type+ is unsigned, or negative integer if the +type+ is signed. For example, if size_t is defined as unsigned, then check_signedness('size_t') would returned +1 and the SIGNEDNESS_OF_SIZE_T=+1 preprocessor macro would be passed to the compiler, and SIGNEDNESS_OF_INT=-1 if check_signedness('int') is done.
Returns the signedness of the given +type+. You may optionally
specify additional +headers+ to search in for the +type+.
If the +type+ is found and is a numeric type, a macro is passed as a
preprocessor constant to the compiler using the +type+ name, in
uppercase, prepended with 'SIGNEDNESS... -
Kernel
. # format(format , *arg) -> String (63058.0) -
format 文字列を C 言語の sprintf と同じように解釈し、 引数をフォーマットした文字列を返します。
...トした文字列を返します。
@param format フォーマット文字列です。
@param arg フォーマットされる引数です。
@see Kernel.#printf,Time#strftime,Date.strptime
=== sprintf フォーマット
Ruby の sprintf フォーマットは基本的に C 言語の sprintf(3)......tf("%p", /e+/) #=> "/e+/"
//}
: d
: i
引数の数値を10進表現の整数として出力します。
引数が整数でなければ関数 Kernel.#Integer と同じ規則で整数に
変換されます。
//emlist[][ruby]{
p sprintf("%d", -1) #=> "-1"
p sprintf("%d", 3.1) #=> "3"
p sprint... -
Kernel
. # sprintf(format , *arg) -> String (63058.0) -
format 文字列を C 言語の sprintf と同じように解釈し、 引数をフォーマットした文字列を返します。
...トした文字列を返します。
@param format フォーマット文字列です。
@param arg フォーマットされる引数です。
@see Kernel.#printf,Time#strftime,Date.strptime
=== sprintf フォーマット
Ruby の sprintf フォーマットは基本的に C 言語の sprintf(3)......tf("%p", /e+/) #=> "/e+/"
//}
: d
: i
引数の数値を10進表現の整数として出力します。
引数が整数でなければ関数 Kernel.#Integer と同じ規則で整数に
変換されます。
//emlist[][ruby]{
p sprintf("%d", -1) #=> "-1"
p sprintf("%d", 3.1) #=> "3"
p sprint... -
Kernel
. # Rational(x , y = 1) -> Rational (63040.0) -
引数を有理数(Rational)に変換した結果を返します。
...スコアで繋いだ形式
"1.2/3" のように、分子を実数にする事も可能ですが、分母には指定できませ
ん。また、Kernel.#Integer とは違い "0x10" のような進数を表す接頭
辞を含めた指定は行えません。
//emlist[例][ruby]{
Rational("1/3")... -
Kernel
. # BigDecimal(s) -> BigDecimal (63022.0) -
引数で指定した値を表す BigDecimal オブジェクトを生成します。
引数で指定した値を表す BigDecimal オブジェクトを生成します。
@param s 数値を表現する初期値を文字列、Integer、
Float、Rational、BigDecimal オブジェクトのい
ずれかで指定します。
文字列中のスペースは無視されます。また、判断できない文字が出現
した時点で文字列は終了したものとみなされます。
@param n 必要な有効桁数(self の最大有効桁数)を整数で指定します。 n が
0 または省略されたときは、n の値は s の有効桁数とみなされます。... -
Kernel
. # BigDecimal(s , n) -> BigDecimal (63022.0) -
引数で指定した値を表す BigDecimal オブジェクトを生成します。
引数で指定した値を表す BigDecimal オブジェクトを生成します。
@param s 数値を表現する初期値を文字列、Integer、
Float、Rational、BigDecimal オブジェクトのい
ずれかで指定します。
文字列中のスペースは無視されます。また、判断できない文字が出現
した時点で文字列は終了したものとみなされます。
@param n 必要な有効桁数(self の最大有効桁数)を整数で指定します。 n が
0 または省略されたときは、n の値は s の有効桁数とみなされます。... -
Kernel
. # putc(ch) -> object (63022.0) -
文字 ch を 標準出力 $stdout に出力します。
文字 ch を 標準出力 $stdout に出力します。
ch が数値なら 0 〜 255 の範囲の対応する文字を出力します。
ch が文字列なら、その先頭1文字を出力します。
どちらでもない場合は、ch.to_int で整数に変換を試みます。
@param ch 出力する文字です。数または文字列で指定します。
@return ch を返します
@raise RangeError Bignum を引数にした場合に発生します。
@raise IOError 標準出力が書き込み用にオープンされていなければ発生します。
@raise Errno::EXXX 出力に失敗した場合に発生します。
@... -
Kernel
. # test(cmd , file1 , file2) -> bool (63010.0) -
2ファイル間のファイルテストを行います。
2ファイル間のファイルテストを行います。
@param cmd 以下に示す文字リテラル、文字列、あるいは同じ文字を表す数値
です。文字列の場合はその先頭の文字だけをコマンドとみなします。
@param file1 テストするファイルのパスを表す文字列か IO オブジェクトを指定します。
@param file2 テストするファイルのパスを表す文字列か IO オブジェクトを指定します。
@return 真偽値を返します。
以下は cmd として指定できる文字リテラルとその意味です。
: ?=
ファイル1とファイル2の最終更新時刻が等しい
: ?>
フ...