種類
- モジュール関数 (91)
- インスタンスメソッド (90)
- 変数 (84)
- 定数 (1)
ライブラリ
キーワード
-
$ ! (1) -
$ " (1) -
$ $ (1) -
$ & (1) -
$ & # 39; (1) -
$ * (1) -
$ + (1) -
$ , (1) -
$ -0 (1) -
$ -F (1) -
$ -I (1) -
$ -K (1) -
$ -i (1) -
$ -v (1) -
$ -w (1) -
$ . (1) -
$ / (1) -
$ 0 (1) -
$ 1 (1) -
$ 10 (1) -
$ 11 (1) -
$ 2 (1) -
$ 3 (1) -
$ 4 (1) -
$ 5 (1) -
$ 6 (1) -
$ 7 (1) -
$ 8 (1) -
$ 9 (1) -
$ : (1) -
$ ; (1) -
$ < (1) -
$ > (1) -
$ ? (1) -
$ @ (1) -
$ ARGV (1) -
$ CFLAGS (1) -
$ CHILD _ STATUS (1) -
$ DEFAULT _ INPUT (1) -
$ DEFAULT _ OUTPUT (1) -
$ ERROR _ INFO (1) -
$ ERROR _ POSITION (1) -
$ FIELD _ SEPARATOR (1) -
$ FILENAME (1) -
$ FS (1) -
$ IGNORECASE (1) -
$ INPUT _ LINE _ NUMBER (1) -
$ INPUT _ RECORD _ SEPARATOR (1) -
$ KCODE (1) -
$ LAST _ MATCH _ INFO (1) -
$ LAST _ PAREN _ MATCH (1) -
$ LAST _ READ _ LINE (1) -
$ LDFLAGS (1) -
$ LOADED _ FEATURES (1) -
$ LOAD _ PATH (1) -
$ MATCH (1) -
$ NR (1) -
$ OFS (1) -
$ ORS (1) -
$ OUTPUT _ FIELD _ SEPARATOR (1) -
$ OUTPUT _ RECORD _ SEPARATOR (1) -
$ PID (1) -
$ POSTMATCH (1) -
$ PREMATCH (1) -
$ PROCESS _ ID (1) -
$ PROGRAM _ NAME (1) -
$ RS (1) -
$ SAFE (1) -
$ VERBOSE (1) -
$ \ (1) -
$ _ (1) -
$ ` (1) -
$ archdir (1) -
$ defs (1) -
$ hdrdir (1) -
$ libdir (1) -
$ libs (1) -
$ sitearchdir (1) -
$ sitelibdir (1) -
$ srcdir (1) -
$ stdin (1) -
$ stdout (1) -
$ topdir (1) -
$ ~ (1) - BigDecimal (2)
- CONFIG (1)
- Complex (2)
- Digest (1)
- Integer (1)
- JSON (1)
- Rational (1)
- String (1)
- URI (1)
-
_ _ callee _ _ (1) -
_ _ dir _ _ (1) -
_ _ method _ _ (1) - ` (1)
-
arg
_ config (1) -
at
_ exit (1) - autoload (1)
- autoload? (1)
- binding (1)
-
block
_ given? (1) - caller (3)
-
caller
_ locations (2) - catch (2)
-
cc
_ command (1) -
check
_ signedness (2) -
check
_ sizeof (2) - chomp (1)
- chop (1)
-
convertible
_ int (2) -
cpp
_ command (1) -
create
_ header (1) -
create
_ makefile (1) -
create
_ tmpsrc (1) - desc (1)
-
dir
_ config (1) - directory (1)
-
dummy
_ makefile (1) -
enable
_ config (2) - eval (1)
- exec (4)
- exit (1)
- exit! (1)
- fail (3)
- file (1)
-
file
_ create (1) -
find
_ executable (1) -
find
_ header (1) -
find
_ library (2) -
find
_ type (2) - fork (2)
- format (1)
- gem (1)
- gets (1)
-
global
_ variables (1) - gsub (2)
-
have
_ func (2) -
have
_ header (2) -
have
_ library (2) -
have
_ macro (2) -
have
_ struct _ member (2) -
have
_ type (2) -
have
_ var (2) - import (1)
- install (1)
-
install
_ files (1) -
install
_ rb (1) - iterator? (1)
- j (1)
- jj (1)
- libpathflag (1)
-
link
_ command (1) - load (1)
-
local
_ variables (1) - loop (1)
-
merge
_ libs (1) - mkdir (1)
- modified? (1)
- multitask (1)
- namespace (1)
- open (4)
- print (1)
- printf (2)
-
psych
_ y (1) - puts (1)
- raise (3)
- rand (2)
- readline (1)
- readlines (1)
- require (2)
-
require
_ relative (1) -
rm
_ f (1) -
rm
_ rf (1) - rmdir (1)
- select (1)
- sleep (2)
- spawn (4)
- sprintf (1)
- srand (2)
- sub (2)
- syscall (1)
- system (4)
- test (2)
- throw (1)
- time (1)
- timeout (2)
-
trace
_ var (3) - trap (2)
-
try
_ compile (2) -
try
_ constant (2) -
try
_ func (2) -
try
_ link (2) -
try
_ run (2) -
try
_ static _ assert (2) -
try
_ type (2) -
try
_ var (2) -
untrace
_ var (1) -
wait
_ writable (1) - warn (1)
-
with
_ config (2) -
with
_ werror (2) - xmp (1)
- xpopen (1)
- xsystem (1)
- y (1)
検索結果
先頭5件
-
Kernel
. # binding -> Binding (37204.0) -
変数・メソッドなどの環境情報を含んだ Binding オブジェクトを 生成して返します。通常、Kernel.#eval の第二引数として使います。
...変数・メソッドなどの環境情報を含んだ Binding オブジェクトを
生成して返します。通常、Kernel.#eval の第二引数として使います。
//emlist[例][ruby]{
def foo
a = 1
binding
end
eval("p a", foo) #=> 1
//}
@see Kernel.#eval,Object::TOPLEVEL_BINDING... -
Kernel
$ $ INPUT _ LINE _ NUMBER -> Integer (36922.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
# wait _ writable -> () (36604.0) -
ファイルが書き込み可能になるまで待ちます。
ファイルが書き込み可能になるまで待ちます。
ruby -run -e wait_writable -- [OPTION] FILE
-n RETRY リトライ回数
-w SEC リトライごとに待つ秒数
-v 詳細表示 -
Kernel
# libpathflag(libpath = $ DEFLIBPATH| $ LIBPATH) -> String (19204.0) -
与えられた libpath を -L 付きの文字列に変換して返します。
与えられた libpath を -L 付きの文字列に変換して返します。
@param libpath LIBPATH に指定する値を指定します。 -
Kernel
# check _ signedness(type , headers = nil , opts = nil) -> "signed" | "unsigned" | nil (18904.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 (18904.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
# enable _ config(config , default) {|config , default| . . . } -> bool | String (18904.0) -
configure のオプションを検査します。
configure のオプションを検査します。
configure のオプションに --enable-<config> が指定された場合は、真を返し
ます。--disable-<config> が指定された場合は。偽を返します。どちらでもな
い場合は default を返します。
これはデバッグ情報などのカスタム定義を、追加するのに役立ちます。
@param config configure のオプションの名前を指定します。
@param default デフォルト値を返します。
例
require 'mkmf'
if enable_config("debug")
... -
Kernel
# find _ executable(bin , path = nil) -> String | nil (18904.0) -
パス path から実行ファイル bin を探します。
パス path から実行ファイル bin を探します。
実行ファイルが見つかった場合は、そのフルパスを返します。
実行ファイルが見つからなかった場合は、nilを返します。
このメソッドは Makefile を変更しません。
@param bin 実行ファイルの名前を指定します。
@param path パスを指定します。デフォルトは環境変数 PATH です。
環境変数 PATH が定義されていない場合は /usr/local/bin,
/usr/ucb, /usr/bin, /bin を使います。 -
Kernel
. # Integer(arg , base = 0) -> Integer (18676.0) -
引数を整数 (Fixnum,Bignum) に変換した結果を返します。
引数を整数
(Fixnum,Bignum)
に変換した結果を返します。
引数が数値の場合は直接変換し(小数点以下切り落とし)、
文字列の場合は、進数を表す接頭辞を含む整数表現とみなせる文字列のみ
変換します。
数値と文字列以外のオブジェクトに対しては arg.to_int, arg.to_i を
この順に使用して変換します。
@param arg 変換対象のオブジェクトです。
@param base 基数として0か2から36の整数を指定します(引数argに文字列を指
定した場合のみ)。省略するか0を指定した場合はプリフィクスか
ら基数を... -
Kernel
$ $ LAST _ READ _ LINE -> String | nil (18640.0) -
$_ の別名
$_ の別名
1 e
2 f
3 g
4 h
5 i
# end of a.txt
ruby -rEnglish -ne'p $LAST_READ_LINE' a.txt
#=>
"1 e\n"
"2 f\n"
"3 g\n"
"4 h\n"
"5 i\n" -
Kernel
$ $ CHILD _ STATUS -> Process :: Status | nil (18622.0) -
$? の別名
$? の別名
require "English"
out = `wget https://www.ruby-lang.org/en/about/license.txt -O - 2>/dev/null`
if $CHILD_STATUS.to_i == 0
print "wget success\n"
out.split(/\n/).each { |line|
printf "%s\n", line
}
else
print "wget failed\n"
end -
Kernel
. # Rational(x , y = 1) -> Rational (18622.0) -
引数を有理数(Rational)に変換した結果を返します。
...スコアで繋いだ形式
"1.2/3" のように、分子を実数にする事も可能ですが、分母には指定できませ
ん。また、Kernel.#Integer とは違い "0x10" のような進数を表す接頭
辞を含めた指定は行えません。
//emlist[例][ruby]{
Rational("1/3")... -
Kernel
# arg _ config(config , default) { . . . } -> object | String | true | nil (18604.0) -
configure オプション --config の値を返します。
configure オプション --config の値を返します。
@param config オプションを文字列で指定します。
@param default 引数 config で指定したオプションのデフォルト値を指定します。
@return オプションが指定されてた場合は true を、指定されなかった場合は
nil を返します。
引数 default、あるいはブロックを指定すると、オプションが指定さ
れていない場合に引数 default の値かブロックの評価結果を返します
(両方指定した場合はブロックが優先されます)... -
Kernel
# create _ makefile(target , srcprefix = nil) -> true (18604.0) -
@todo
...@todo
Kernel#have_library などの各種検査の結果を元に、拡張ライブラリを
ビルドするための Makefile を生成します。
extconf.rb は普通このメソッドの呼び出しで終ります。
@param target ターゲットとなる拡張ライブラリの名前を指......create_makefile('foo') {|conf|
[
*conf,
"MACRO_YOU_NEED = something",
]
}
ソースディレクトリに depend ファイルが存在する場合、その内容が
Kernel#depend_rules メソッドで整形されて、生成される Makefile に加えられます。... -
Kernel
# directory(dir) -> () (18604.0) -
与えられたディレクトリを作成するタスクを定義します。
与えられたディレクトリを作成するタスクを定義します。
@param dir 作成するディレクトリを指定します。
例:
directory 'testdata/doc' -
Kernel
# enable _ config(config , default) -> bool | String (18604.0) -
configure のオプションを検査します。
configure のオプションを検査します。
configure のオプションに --enable-<config> が指定された場合は、真を返し
ます。--disable-<config> が指定された場合は。偽を返します。どちらでもな
い場合は default を返します。
これはデバッグ情報などのカスタム定義を、追加するのに役立ちます。
@param config configure のオプションの名前を指定します。
@param default デフォルト値を返します。
例
require 'mkmf'
if enable_config("debug")
... -
Kernel
# file(*args) { . . . } -> Rake :: FileTask (18604.0) -
ファイルタスクを定義します。
ファイルタスクを定義します。
@param args ファイル名と依存ファイル名を指定します。
例:
file "config.cfg" => ["config.template"] do
open("config.cfg", "w") do |outfile|
open("config.template") do |infile|
while line = infile.gets
outfile.puts line
end
end
end
end
@see Rake:... -
Kernel
# file _ create(*args) { . . . } -> Rake :: FileCreationTask (18604.0) -
ファイルを作成するタスクを定義します。
...ファイルを作成するタスクを定義します。
主に Kernel.#directory を定義するために使用します。... -
Kernel
# have _ library(lib , func = nil , headers = nil) -> bool (18604.0) -
ライブラリ lib がシステムに存在し、関数 func が定義されているかどうかをチェックします。 チェックが成功すれば $libs に lib を追加し true を返します。 チェックが失敗したら false を返します。
ライブラリ lib がシステムに存在し、関数 func が定義されているかどうかをチェックします。
チェックが成功すれば $libs に lib を追加し true を返します。
チェックが失敗したら false を返します。
@param lib ライブラリの名前を指定します。
@param func 検査する関数名を指定します。
nil または空文字列のときは、"main" になります。
@param headers 追加のヘッダファイルを指定します。 -
Kernel
# have _ library(lib , func = nil , headers = nil) { . . . } -> bool (18604.0) -
ライブラリ lib がシステムに存在し、関数 func が定義されているかどうかをチェックします。 チェックが成功すれば $libs に lib を追加し true を返します。 チェックが失敗したら false を返します。
ライブラリ lib がシステムに存在し、関数 func が定義されているかどうかをチェックします。
チェックが成功すれば $libs に lib を追加し true を返します。
チェックが失敗したら false を返します。
@param lib ライブラリの名前を指定します。
@param func 検査する関数名を指定します。
nil または空文字列のときは、"main" になります。
@param headers 追加のヘッダファイルを指定します。 -
Kernel
# link _ command(ldflags , opt = "" , libpath = $ DEFLIBPATH| $ LIBPATH) -> String (18604.0) -
実際にリンクする際に使用するコマンドを返します。
実際にリンクする際に使用するコマンドを返します。
@param ldflags LDFLAGS に追加する値を指定します。
@param opt LIBS に追加する値を指定します。
@param libpath LIBPATH に指定する値を指定します。
@see RbConfig.expand -
Kernel
# merge _ libs(*libs) -> [String] (18604.0) -
@todo 使われてない
@todo 使われてない
@param libs ??? -
Kernel
# multitask(args) { . . . } -> Rake :: MultiTask (18604.0) -
事前タスクを並列実行するタスクを定義します。
事前タスクを並列実行するタスクを定義します。
与えられた事前タスクを実行する順序は不定です。
例:
multitask :deploy => [:deploy_gem, :deploy_rdoc] -
Kernel
$ $ INPUT _ RECORD _ SEPARATOR -> String | nil (18604.0) -
$/ の別名
$/ の別名
require "English"
$INPUT_RECORD_SEPARATOR = '|'
array = []
while line = DATA.gets
array << line
end
p array #=> ["ugo|", "ego|", "fogo\n"]
__END__
ugo|ego|fogo -
Kernel
. # BigDecimal(s) -> BigDecimal (18604.0) -
引数で指定した値を表す BigDecimal オブジェクトを生成します。
引数で指定した値を表す BigDecimal オブジェクトを生成します。
@param s 数値を表現する初期値を文字列、Integer、
Float、Rational、BigDecimal オブジェクトのい
ずれかで指定します。
文字列中のスペースは無視されます。また、判断できない文字が出現
した時点で文字列は終了したものとみなされます。
@param n 必要な有効桁数(self の最大有効桁数)を整数で指定します。 n が
0 または省略されたときは、n の値は s の有効桁数とみなされます。... -
Kernel
. # BigDecimal(s , n) -> BigDecimal (18604.0) -
引数で指定した値を表す BigDecimal オブジェクトを生成します。
引数で指定した値を表す BigDecimal オブジェクトを生成します。
@param s 数値を表現する初期値を文字列、Integer、
Float、Rational、BigDecimal オブジェクトのい
ずれかで指定します。
文字列中のスペースは無視されます。また、判断できない文字が出現
した時点で文字列は終了したものとみなされます。
@param n 必要な有効桁数(self の最大有効桁数)を整数で指定します。 n が
0 または省略されたときは、n の値は s の有効桁数とみなされます。... -
Kernel
. # String(arg) -> String (18604.0) -
引数を文字列(String)に変換した結果を返します。
引数を文字列(String)に変換した結果を返します。
arg.to_s を呼び出して文字列に変換します。
arg が文字列の場合、何もせず arg を返します。
@param arg 変換対象のオブジェクトです。
@raise TypeError to_s の返り値が文字列でなければ発生します。
//emlist[例][ruby]{
class Foo
def to_s
"hogehoge"
end
end
arg = Foo.new
p String(arg) #=> "hogehoge"
//}
@see Object#to_s,String -
Kernel
. # caller _ locations(range) -> [Thread :: Backtrace :: Location] | nil (18604.0) -
現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。
...(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9, 13]
# => ["/Users/user/test.rb", "/Users/user/test.rb"]
test3(2, 1)
# => ["/Users/user/test.rb:13:in `test3'"]
# => [13]
# => ["/Users/user/test.rb"]
//}
@see Thread::Backtrace::Location, Kernel.#caller... -
Kernel
. # caller _ locations(start = 1 , length = nil) -> [Thread :: Backtrace :: Location] | nil (18604.0) -
現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。
...(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9, 13]
# => ["/Users/user/test.rb", "/Users/user/test.rb"]
test3(2, 1)
# => ["/Users/user/test.rb:13:in `test3'"]
# => [13]
# => ["/Users/user/test.rb"]
//}
@see Thread::Backtrace::Location, Kernel.#caller... -
Kernel
. # fail(error _ type , message = nil , backtrace = caller(0) , cause: $ !) -> () (18604.0) -
例外を発生させます。 発生した例外は変数 $! に格納されます。また例外が 発生した時のスタックトレースは変数 $@ に格納され ます。発生した例外は rescue 節で捕捉できます。
...します。
@param message 例外のメッセージとなる文字列です。
@param backtrace 例外発生時のスタックトレースで、Kernel.#caller の戻り値と同じ
形式で指定しなければいけません。
@param cause 現在の例外($!)の代わりに Exception#cause に......end
foo(4) #=> in method.in rescue.in method.in else.in ensure.
//}
//emlist[例3][ruby]{
class MyException
def exception(mesg=nil)
SecurityError.new(mesg)
end
end
begin
raise MyException.new
rescue SecurityError
p $! #=> #<SecurityError: SecurityError>
end
//}
@see Kernel.#caller... -
Kernel
. # readline(rs = $ / ) -> String (18604.0) -
ARGFから一行読み込んで、それを返します。 行の区切りは引数 rs で指定した文字列になります。
...t ---
hello
it
common
# --- c.txt ---
ARGF
# スクリプトに指定した引数 (Object::ARGV を参照) をファイル名と
# みなして、それらのファイルを連結した 1 つの仮想ファイルを表すオブジェクトです。
//}
@see $/,ARGF,Kernel.#readlines,Kernel.#gets... -
Kernel
. # readlines(rs = $ / ) -> [String] (18604.0) -
ARGFを Kernel.#gets(rs) でEOFまで読み込んで、その各行を要素としてもつ配列を返します。 行の区切りは引数 rs で指定した文字列になります。
...ARGFを Kernel.#gets(rs) でEOFまで読み込んで、その各行を要素としてもつ配列を返します。
行の区切りは引数 rs で指定した文字列になります。
rs に nil を指定すると行区切りなしとみなします。
空文字列 "" を指定すると連続......s("") #=> ["hello\nit\n\n", "common\n", "hello\nit\n\n", "common\n"]
ARGV << 'b.txt' << 'b.txt'
p readlines('it') #=> ["hello\nit", "\n\ncommon\n", "hello\nit", "\n\ncommon\n"]
p readlines #=> []
//}
//emlist[b.txt][ruby]{
hello
it
common
//}
@see $/,ARGF,Kernel.#gets, Kernel.#readline... -
Kernel
$ $ -i -> String | nil (18379.0) -
in-place 置換モードで用いられます。
in-place 置換モードで用いられます。
コマンドラインオプション -i を指定したとき、空文字列になります。
-i オプションに拡張子を渡した場合にはその拡張子が文字列として格納されます。
-i オプションが指定されていない時の値は nil です。
スクリプト内で $-i に代入することもでき、
その場合は Object::ARGV の次の
ファイルを読み込み始めるタイミングで in-place 置換を開始します。
この変数はグローバルスコープです。
@see spec/rubycmd -
Kernel
$ $ -I -> [String] (18361.0) -
Rubyライブラリをロードするときの検索パスです。
...Rubyライブラリをロードするときの検索パスです。
Kernel.#load や Kernel.#require
がファイルをロードする時に検索するディレクトリのリストを含む配列です。
起動時にはコマンドラインオプション -I で指定したディレクトリ、... -
Kernel
. # at _ exit { . . . } -> Proc (18340.0) -
与えられたブロックをインタプリタ終了時に実行します。
...Proc オブジェクトで返します。
//emlist[例][ruby]{
3.times do |i|
at_exit{puts "at_exit#{i}"}
end
END{puts "END"}
at_exit{puts "at_exit"}
puts "main_end"
#=> main_end
# at_exit
# END
# at_exit2
# at_exit1
# at_exit0
//}
@see d:spec/control#END,Kernel.#exit!,Kernel.#fork... -
Kernel
# timeout(sec) {|i| . . . . } -> object (18328.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
ブロックを sec 秒の期限付きで実行します。
ブロックの実行時間が制限を過ぎたときは例外
Timeout::Error が発生します。
exception_class を指定した場合には Timeout::Error の代わりに
その例外が発生します。
ブロックパラメータ i は sec がはいります。
また sec が 0 もしくは nil のときは制限時間なしで
ブロックを実行します。
@param sec タイムアウトする時間を秒数で指定します.
@param exception_class タイムアウトした時、発生させる例外を指定します.
=== 注意
timeout に... -
Kernel
# timeout(sec , exception _ class = nil) {|i| . . . . } -> object (18328.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
ブロックを sec 秒の期限付きで実行します。
ブロックの実行時間が制限を過ぎたときは例外
Timeout::Error が発生します。
exception_class を指定した場合には Timeout::Error の代わりに
その例外が発生します。
ブロックパラメータ i は sec がはいります。
また sec が 0 もしくは nil のときは制限時間なしで
ブロックを実行します。
@param sec タイムアウトする時間を秒数で指定します.
@param exception_class タイムアウトした時、発生させる例外を指定します.
=== 注意
timeout に... -
Kernel
# find _ header(header , *paths) -> bool (18322.0) -
与えられた paths から header を検索し、見つかった場合は真を返します。 そうでない場合は偽を返します。
与えられた paths から header を検索し、見つかった場合は真を返します。
そうでない場合は偽を返します。
ヘッダが見つかったディレクトリをコンパイラに渡すコマンドラインオプショ
ンに追加します(-I オプションを経由します)。
@param header ヘッダを指定します。
@param paths ヘッダを検索するパスを指定します。 -
Kernel
$ $ NR -> Integer (18322.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
# Digest(name) -> object (18304.0) -
"MD5"や"SHA1"などのダイジェストを示す文字列 name を指定し、 対応するダイジェストのクラスを取得します。
...で
Digest::MD5などを直接呼び出すと問題があるときはこのメソッドを使
うか、起動時に使用するライブラリを Kernel.#require してください。
@param name "MD5"や"SHA1"などのダイジェストを示す文字列を指定します。
@return Digest::MD5や... -
Kernel
# check _ sizeof(type , headers = nil) -> Integer | nil (18304.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 (18304.0) -
与えられた型のサイズを返します。
与えられた型のサイズを返します。
型 type がシステムに存在する場合は、グローバル変数 $defs に
"-DSIZEOF_type=X" を追加し、型のサイズを返します。型 type がシステムに
存在しない場合は、nil を返します。
例えば、
require 'mkmf'
check_sizeof('mystruct') # => 12
である場合、SIZEOF_MYSTRUCT=12 というプリプロセッサマクロをコンパイラに渡します。
@param type 検査したい型を指定します。
@param headers 追加のヘッダファイルを指定します。 -
Kernel
# convertible _ int(type , headers = nil , opts = nil) (18304.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) { . . . } (18304.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
# dir _ config(target , idefault = nil , ldefault = nil) -> [String , String] (18304.0) -
configure オプション --with-TARGET-dir, --with-TARGET-include, --with-TARGET-lib をユーザが extconf.rb に指定できるようにします。
configure オプション
--with-TARGET-dir,
--with-TARGET-include,
--with-TARGET-lib
をユーザが extconf.rb に指定できるようにします。
--with-TARGET-dir オプションは
システム標準ではない、
ヘッダファイルやライブラリがあるディレクトリをまとめて指定するために使います。
ユーザが extconf.rb に --with-TARGET-dir=PATH を指定したときは
$CFLAGS に "-IPATH/include" を、
$LDFLAGS に "-LPATH/lib" を、
それぞれ追加し... -
Kernel
# dummy _ makefile(srcdir) -> String (18304.0) -
ダミーの Makefile を作成します。
ダミーの Makefile を作成します。
@param srcdir ソースディレクトリを指定します。 -
Kernel
# find _ library(lib , func , *paths) -> bool (18304.0) -
関数 func が定義されたライブラリ lib を探します。
...査してもライブラリ lib が見つからないときは、
変数を変更せず false を返します。
paths を指定しないときは Kernel#have_library と同じ動作です。
@param lib ライブラリ名を指定します。
@param func 関数名を指定します。... -
Kernel
# find _ library(lib , func , *paths) { . . . } -> bool (18304.0) -
関数 func が定義されたライブラリ lib を探します。
...査してもライブラリ lib が見つからないときは、
変数を変更せず false を返します。
paths を指定しないときは Kernel#have_library と同じ動作です。
@param lib ライブラリ名を指定します。
@param func 関数名を指定します。... -
Kernel
# find _ type(type , opt , *headers) -> Array (18304.0) -
静的な型 type がシステムに存在するかどうか検査します。
...な型 type がシステムに存在するかどうか検査します。
@param type 検査したい型の名前を指定します。
@param opt コンパイラに渡す追加のオプションを指定します。
@param headers 追加のヘッダを指定します。
@see Kernel#have_type... -
Kernel
# find _ type(type , opt , *headers) { . . . } -> Array (18304.0) -
静的な型 type がシステムに存在するかどうか検査します。
...な型 type がシステムに存在するかどうか検査します。
@param type 検査したい型の名前を指定します。
@param opt コンパイラに渡す追加のオプションを指定します。
@param headers 追加のヘッダを指定します。
@see Kernel#have_type... -
Kernel
# import(*filenames) (18304.0) -
分割された Rakefile をインポートします。
分割された Rakefile をインポートします。
インポートされたファイルは、現在のファイルが完全にロードされた後でロードされます。
このメソッドはインポートするファイルのどこで呼び出されてもかまいません。
また、インポートされるファイル内に現れるオブジェクトはインポートするファイル内で定義
されているオブジェクトに依存していてもかまいません。
このメソッドは依存関係を定義したファイルを読み込むのによく使われます。
@param filenames インポートする Rakefile を指定します。
例:
import ".depend", "my_rules" -
Kernel
# install -> () (18304.0) -
ファイルをコピーし、その属性を設定します。
ファイルをコピーし、その属性を設定します。
ruby -run -e install -- [OPTION] SOURCE DEST
-p ファイルのアクセス時刻と修正時刻を保持します。
-m chmod と同じようにファイルのパーミッションを設定します。
-v 詳細表示
@see install(1) -
Kernel
# install _ files(mfile , ifiles , map = nil , srcprefix = nil) -> [] (18304.0) -
このメソッドは create_makefile, install_rb が使用します。 内部用のメソッドです。
このメソッドは create_makefile, install_rb が使用します。
内部用のメソッドです。
@param mfile Makefile を表す File のインスタンスです。
@param ifiles インストールするファイルのリストを指定します。
@param map ???
@param srcprefix ソースディレクトリを指定します。 -
Kernel
# install _ rb(mfile , dest , srcdir = nil) -> Array (18304.0) -
このメソッドは create_makefile が使用します。 内部用のメソッドです。
このメソッドは create_makefile が使用します。
内部用のメソッドです。
ディレクトリ srcdir/lib 配下の Ruby スクリプト (*.rb ファイル)
を dest にインストールするための Makefile 規則を mfile に出力します。
srcdir/lib のディレクトリ構造はそのまま dest 配下に反映されます。
@param mfile Makefile を表す File のインスタンスです。
@param dest インストールする先のディレクトリを指定します。
@param srcdir ソースディレクトリを指定します。 -
Kernel
# mkdir -> () (18304.0) -
ディレクトリを作成します。
ディレクトリを作成します。
ruby -run -e mkdir -- [OPTION] DIR
-p ディレクトリが存在してもエラーになりません。
必要であれば親ディレクトリも作成します。
-v 詳細表示
@see mkdir(1) -
Kernel
# modified?(target , times) -> Time | nil (18304.0) -
target が times の全ての要素よりも新しい場合は target の更新時刻を返します。 そうでない場合は nil を返します。target が存在しない場合も nil を返します。
target が times の全ての要素よりも新しい場合は target の更新時刻を返します。
そうでない場合は nil を返します。target が存在しない場合も nil を返します。
@param target 対象のファイル名を指定します。
@param times Time の配列か Time を一つ指定します。 -
Kernel
# require(path) -> bool (18304.0) -
RubyGems を require すると、Kernel#require が Gem を 要求されたときにロードするように置き換えます。
...RubyGems を require すると、Kernel#require が Gem を
要求されたときにロードするように置き換えます。
再定義された Kernel#require を呼び出すと以下の事を行います。
Ruby のロードパスに存在するライブラリを指定した場合はその... -
Kernel
# rmdir -> () (18304.0) -
空のディレクトリを削除します。
空のディレクトリを削除します。
ruby -run -e rmdir -- [OPTION] DIR
-p DIR で指定されたディレクトリとその上位ディレクトリを削除します
-v 詳細表示
@see rmdir(1) -
Kernel
# time(msg , width = 25) { . . . } -> object (18304.0) -
与えられたブロックの実行時間を計測して表示します。
与えられたブロックの実行時間を計測して表示します。
@param msg 表示するメッセージを指定します。
@param width 表示する幅を指定します。
@return ブロックの実行結果を返します。 -
Kernel
# try _ compile(src , opt = "" , *opts) -> bool (18304.0) -
与えられた C のソースコードがコンパイルできた場合は真を返します。 コンパイルできなかった場合は偽を返します。
与えられた C のソースコードがコンパイルできた場合は真を返します。
コンパイルできなかった場合は偽を返します。
ブロックを与えた場合、そのブロックはコンパイル前に評価されます。
ブロック内でソースコードを変更することができます。
@param src C のソースコードを指定します。
@param opt コンパイラに渡すオプションを指定します。
$CFLAGS もコンパイラには渡されます。 -
Kernel
# try _ compile(src , opt = "" , *opts) { . . . } -> bool (18304.0) -
与えられた C のソースコードがコンパイルできた場合は真を返します。 コンパイルできなかった場合は偽を返します。
与えられた C のソースコードがコンパイルできた場合は真を返します。
コンパイルできなかった場合は偽を返します。
ブロックを与えた場合、そのブロックはコンパイル前に評価されます。
ブロック内でソースコードを変更することができます。
@param src C のソースコードを指定します。
@param opt コンパイラに渡すオプションを指定します。
$CFLAGS もコンパイラには渡されます。 -
Kernel
# try _ link(src , opt = "" , *options) -> bool (18304.0) -
C プログラムのソースコード src をコンパイル、リンクします。
C プログラムのソースコード src をコンパイル、リンクします。
このメソッドは $CFLAGS と $LDFLAGS の値もコンパイラまたはリ
ンカに渡します。
問題なくリンクできたら true を返します。
コンパイルとリンクに失敗したら false を返します。
@param src C プログラムのソースコードを指定します。
@param opt リンカにコマンド引数として渡す値を指定します。
例:
require 'mkmf'
if try_link("int main() { sin(0.0); }", '-lm')
$stderr.puts "si... -
Kernel
# try _ link(src , opt = "" , *options) { . . . } -> bool (18304.0) -
C プログラムのソースコード src をコンパイル、リンクします。
C プログラムのソースコード src をコンパイル、リンクします。
このメソッドは $CFLAGS と $LDFLAGS の値もコンパイラまたはリ
ンカに渡します。
問題なくリンクできたら true を返します。
コンパイルとリンクに失敗したら false を返します。
@param src C プログラムのソースコードを指定します。
@param opt リンカにコマンド引数として渡す値を指定します。
例:
require 'mkmf'
if try_link("int main() { sin(0.0); }", '-lm')
$stderr.puts "si... -
Kernel
# try _ static _ assert(expr , headers = nil , opt = "") -> bool (18304.0) -
@todo ???
@todo ???
...
@param expr C 言語の式を指定します。
@param headers 追加のヘッダファイルを指定します。
@param opt コンパイラに渡すオプションを指定します。
$CFLAGS もコンパイラには渡されます。 -
Kernel
# try _ static _ assert(expr , headers = nil , opt = "") { . . . } -> bool (18304.0) -
@todo ???
@todo ???
...
@param expr C 言語の式を指定します。
@param headers 追加のヘッダファイルを指定します。
@param opt コンパイラに渡すオプションを指定します。
$CFLAGS もコンパイラには渡されます。 -
Kernel
# with _ config(config , default = nil) -> bool | String (18304.0) -
configure のオプションを検査します。
configure のオプションを検査します。
configure のオプションに --with-<config> が指定された場合は真を返しま
す。--without-<config> が指定された場合は偽を返します。どちらでもない場
合は default を返します。
これはデバッグ情報などのカスタム定義を、追加するのに役立ちます。
@param config configure のオプションの名前を指定します。
@param default デフォルト値を返します。
例
require 'mkmf'
if with_config("debug")
$defs... -
Kernel
# with _ config(config , default = nil) {|config , default| . . . } -> bool | String (18304.0) -
configure のオプションを検査します。
configure のオプションを検査します。
configure のオプションに --with-<config> が指定された場合は真を返しま
す。--without-<config> が指定された場合は偽を返します。どちらでもない場
合は default を返します。
これはデバッグ情報などのカスタム定義を、追加するのに役立ちます。
@param config configure のオプションの名前を指定します。
@param default デフォルト値を返します。
例
require 'mkmf'
if with_config("debug")
$defs... -
Kernel
# with _ werror(opt , opts = nil) {|opt , opts| . . . } -> object (18304.0) -
@todo 内部用?
@todo 内部用?
???
@param opt ????
@param opts ????
@return ブロックを評価した結果を返します。 -
Kernel
# with _ werror(opt , opts = nil) {|opt| . . . } -> object (18304.0) -
@todo 内部用?
@todo 内部用?
???
@param opt ????
@param opts ????
@return ブロックを評価した結果を返します。 -
Kernel
$ $ DEFAULT _ INPUT -> IO (18304.0) -
$< の別名
$< の別名
require "English"
while line = $DEFAULT_INPUT.gets
p line
end
# end of sample.rb
ruby sample.rb < /etc/passwd
# => "hoge:x:500:501::/home/hoge:/bin/bash\n"
... -
Kernel
$ $ ERROR _ INFO -> Exception | nil (18304.0) -
$! の別名
$! の別名
require "English"
class SomethingError < StandardError; end
begin
raise SomethingError
rescue
p $ERROR_INFO.backtrace #=> ["sample.rb:5"]
p $ERROR_INFO.to_s #=> "SomethingError"
end -
Kernel
$ $ ERROR _ POSITION -> [String] | nil (18304.0) -
$@ の別名
$@ の別名
require "English"
class SomethingError < StandardError; end
begin
raise SomethingError
rescue
p $ERROR_POSITION #=> ["sample.rb:5"]
end -
Kernel
$ $ FIELD _ SEPARATOR -> String | nil (18304.0) -
$; の別名
$; の別名
require "English"
str = "hoge,fuga,ugo,bar,foo"
p str.split #=> ["hoge,fuga,ugo,bar,foo"]
$FIELD_SEPARATOR = ","
p str.split #=> ["hoge", "fuga", "ugo", "bar", "foo"] -
Kernel
$ $ FILENAME -> String (18304.0) -
仮想ファイル Object::ARGF で現在読み込み中のファイル名です。 ARGF.class#filename と同じです。
仮想ファイル Object::ARGF で現在読み込み中のファイル名です。
ARGF.class#filename と同じです。
この変数はグローバルスコープです。 -
Kernel
$ $ IGNORECASE -> bool (18304.0) -
過去との互換性のために残されていますが、もはや何の意味もありません。
過去との互換性のために残されていますが、もはや何の意味もありません。
値は常に false です。代入しても無視されます。
$= の別名
require "English"
$IGNORECASE = true # => warning: variable $= is no longer effective; ignored
$IGNORECASE # => warning: variable $= is no longer effective
# false -
Kernel
$ $ LAST _ MATCH _ INFO -> MatchData | nil (18304.0) -
$~ の別名
$~ の別名
require "English"
str = "<a href=https://www.ruby-lang.org/en/about/license.txt>license</a>"
if /<a href=(.+?)>/ =~ str
p $LAST_MATCH_INFO[0] #=> "<a href=https://www.ruby-lang.org/en/about/license.txt>"
p $LAST_MATCH_INFO[1] #=> "https://www.ruby-lang.org/en/about/license.t... -
Kernel
$ $ PID -> Integer (18304.0) -
$$ の別名
$$ の別名
require "English"
p sprintf("something%s", $PID) #=> "something5543" など -
Kernel
$ $ PROCESS _ ID -> Integer (18304.0) -
$$ の別名
$$ の別名
require "English"
p sprintf("something%s", $PID) #=> "something5543" など -
Kernel
$ $ archdir -> String (18304.0) -
マシン固有のライブラリを置くディレクトリです。 通常は "/usr/local/lib/ruby/バージョン/arch" です。
マシン固有のライブラリを置くディレクトリです。
通常は "/usr/local/lib/ruby/バージョン/arch" です。 -
Kernel
$ $ hdrdir -> String (18304.0) -
Ruby のヘッダファイル ruby.h が存在するディレクトリです。 通常は $archdir と同じで、"/usr/local/lib/ruby/バージョン/arch" です。
Ruby のヘッダファイル ruby.h が存在するディレクトリです。
通常は $archdir と同じで、"/usr/local/lib/ruby/バージョン/arch" です。 -
Kernel
$ $ libdir -> String (18304.0) -
Ruby のライブラリを置くディレクトリです。 通常は "/usr/local/lib/ruby/バージョン" です。
Ruby のライブラリを置くディレクトリです。
通常は "/usr/local/lib/ruby/バージョン" です。 -
Kernel
$ $ libs -> String (18304.0) -
拡張ライブラリをリンクするときに 一緒にリンクされるライブラリを指定する文字列です。
...ライブラリを指定する文字列です。
この変数の値は、例えば
"-lfoo -lbar"
のような形式の文字列です。
Kernel#have_library または Kernel#find_library
を呼び出すと、その検査結果が
間に空白をはさみつつ $libs に連結されます。... -
Kernel
$ $ sitearchdir -> String (18304.0) -
サイト固有でかつマシン固有のライブラリを置くディレクトリです。 通常は "/usr/local/lib/ruby/site_ruby/バージョン/arch" です。
サイト固有でかつマシン固有のライブラリを置くディレクトリです。
通常は "/usr/local/lib/ruby/site_ruby/バージョン/arch" です。 -
Kernel
$ $ sitelibdir -> String (18304.0) -
サイト固有のライブラリを置くディレクトリです。 通常は "/usr/local/lib/ruby/site_ruby/バージョン" です。
サイト固有のライブラリを置くディレクトリです。
通常は "/usr/local/lib/ruby/site_ruby/バージョン" です。 -
Kernel
$ $ srcdir -> String (18304.0) -
Ruby インタプリタを make したときのソースディレクトリです。
Ruby インタプリタを make したときのソースディレクトリです。 -
Kernel
$ $ stdin -> object (18304.0) -
標準入力です。
...# 入力する
$stdin = STDIN # 元に戻す
//}
ただし、Kernel.#gets など、特定の組み込みメソッドは
$stdin オブジェクトにメソッドを転送して実装されています。
従って、Kernel.#gets などが正しく動作するには、
$stdin オブジェク... -
Kernel
$ $ topdir -> String (18304.0) -
拡張ライブラリを make するためのヘッダファイル、 ライブラリ等が存在するディレクトリです。 通常は $archdir と同じで、"/usr/local/lib/ruby/バージョン/arch" です。
拡張ライブラリを make するためのヘッダファイル、
ライブラリ等が存在するディレクトリです。
通常は $archdir と同じで、"/usr/local/lib/ruby/バージョン/arch" です。 -
Kernel
. # URI(uri _ str) -> object (18304.0) -
与えられた URI から該当する URI::Generic のサブクラスのインスタンスを生成して 返します。scheme が指定されていない場合は、URI::Generic オブジェクトを返します。
与えられた URI から該当する URI::Generic のサブクラスのインスタンスを生成して
返します。scheme が指定されていない場合は、URI::Generic オブジェクトを返します。
@param uri_str パースしたい URI を文字列として与えます。
@raise URI::InvalidURIError パースに失敗した場合に発生します。
@see URI.parse -
Kernel
. # _ _ dir _ _ -> String | nil (18304.0) -
現在のソースファイル(__FILE__)のあるディレクトリ名を正規化された絶対パ スで返します。シンボリックリンクも解決されます。また、__FILE__ が nil の場合は nil を返します。
現在のソースファイル(__FILE__)のあるディレクトリ名を正規化された絶対パ
スで返します。シンボリックリンクも解決されます。また、__FILE__ が nil
の場合は nil を返します。 -
Kernel
. # block _ given? -> bool (18304.0) -
メソッドにブロックが与えられていれば真を返します。
メソッドにブロックが与えられていれば真を返します。
このメソッドはカレントコンテキストにブロックが与えられているかを調べるので、
メソッド内部以外で使っても単に false を返します。
iterator? は (ブロックが必ずイテレートするとはいえないので)推奨されていないの
で block_given? を使ってください。
//emlist[例][ruby]{
def check
if block_given?
puts "Block is given."
else
puts "Block isn't given."
end
end
check{} #=... -
Kernel
. # exit!(status = false) -> () (18304.0) -
Rubyプログラムの実行を即座に終了します。 status として整数が与えられた場合、その値を Ruby コマンドの終了ステータスとします。 デフォルトの終了ステータスは 1 です。
...XIT_FAILURE の値なので、正確には環境依存です。
exit! は exit とは違って、例外処理などは一切行ないませ
ん。 Kernel.#fork の後、子プロセスを終了させる時などに用
いられます。
@param status 終了ステータスを整数か true また......T.sync = true #表示前に終了しないようにする
puts 'start'
begin
puts 'start1...'
exit!
ensure
puts 'end1...' #実行されない
end
puts 'end' #実行されない
#=> start
# start1...
#終了ステータス:1
//}
@see Kernel.#exit,Kernel.#abort,Kernel.#at_exit,Kernel.#fork... -
Kernel
. # exit(status = true) -> () (18304.0) -
Rubyプログラムの実行を終了します。status として整 数が与えられた場合、その値を Ruby コマンドの終了ステータスとします。 デフォルトの終了ステータスは 0(正常終了)です。
...puts "end1 with #{err.inspect}"
end
begin
puts 'start2...'
exit
ensure
puts 'end2...'
end
puts 'end' #実行されない
#=> start
# start1...
# end1 with #<SystemExit: exit>
# start2...
# end2...
#終了ステータス:0
//}
@see Kernel.#exit!,Kernel.#abort, d:spec/control#begin... -
Kernel
. # fail -> () (18304.0) -
例外を発生させます。 発生した例外は変数 $! に格納されます。また例外が 発生した時のスタックトレースは変数 $@ に格納され ます。発生した例外は rescue 節で捕捉できます。
...します。
@param message 例外のメッセージとなる文字列です。
@param backtrace 例外発生時のスタックトレースで、Kernel.#caller の戻り値と同じ
形式で指定しなければいけません。
@param cause 現在の例外($!)の代わりに Exception#cause に......end
foo(4) #=> in method.in rescue.in method.in else.in ensure.
//}
//emlist[例3][ruby]{
class MyException
def exception(mesg=nil)
SecurityError.new(mesg)
end
end
begin
raise MyException.new
rescue SecurityError
p $! #=> #<SecurityError: SecurityError>
end
//}
@see Kernel.#caller... -
Kernel
. # fail(message , cause: $ !) -> () (18304.0) -
例外を発生させます。 発生した例外は変数 $! に格納されます。また例外が 発生した時のスタックトレースは変数 $@ に格納され ます。発生した例外は rescue 節で捕捉できます。
...します。
@param message 例外のメッセージとなる文字列です。
@param backtrace 例外発生時のスタックトレースで、Kernel.#caller の戻り値と同じ
形式で指定しなければいけません。
@param cause 現在の例外($!)の代わりに Exception#cause に......end
foo(4) #=> in method.in rescue.in method.in else.in ensure.
//}
//emlist[例3][ruby]{
class MyException
def exception(mesg=nil)
SecurityError.new(mesg)
end
end
begin
raise MyException.new
rescue SecurityError
p $! #=> #<SecurityError: SecurityError>
end
//}
@see Kernel.#caller... -
Kernel
. # global _ variables -> [Symbol] (18304.0) -
プログラム中で定義されているグローバル変数(`$'で始まる変数)名の 配列を返します。
...グラム中で定義されているグローバル変数(`$'で始まる変数)名の
配列を返します。
//emlist[例][ruby]{
p global_variables #=> [:$;, :$-F, :$@, ... ]
//}
@see Kernel.#local_variables,Object#instance_variables,Module.constants,Module#constants,Module#class_variables... -
Kernel
. # iterator? -> bool (18304.0) -
メソッドにブロックが与えられていれば真を返します。
メソッドにブロックが与えられていれば真を返します。
このメソッドはカレントコンテキストにブロックが与えられているかを調べるので、
メソッド内部以外で使っても単に false を返します。
iterator? は (ブロックが必ずイテレートするとはいえないので)推奨されていないの
で block_given? を使ってください。
//emlist[例][ruby]{
def check
if block_given?
puts "Block is given."
else
puts "Block isn't given."
end
end
check{} #=... -
Kernel
. # local _ variables -> [Symbol] (18304.0) -
現在のスコープで定義されているローカル変数名の配列を返します。
...現在のスコープで定義されているローカル変数名の配列を返します。
//emlist[例][ruby]{
yuyu = 0
p local_variables #=> [:yuyu]
//}
@see Kernel.#global_variables,Object#instance_variables,Module.constants,Module#constants,Module#class_variables... -
Kernel
. # print(*arg) -> nil (18304.0) -
引数を順に標準出力 $stdout に出力します。引数が与えられない時には変数 $_ の値を出力します。
...た場合に発生します。
//emlist[例][ruby]{
print "Hello, world!"
print "Regexp is",/ant/
print nil
print "\n"
#=> Hello, world!Regexp is(?-mix:ant)
$_ = "input"
$, = "<and>"
$\ = "<end>\n"
print
print "AA","BB"
#=> input<end>
#=> AA<and>BB<end>
//}
@see Kernel.#puts,Kernel.#p,IO#print... -
Kernel
. # printf(format , *arg) -> nil (18304.0) -
C 言語の printf と同じように、format に従い引数を文字列に変 換して port に出力します。
...out に出力します。
引数を 1 つも指定しなければ何もしません。
Ruby における format 文字列の拡張については
Kernel.#sprintfの項を参照してください。
@param port 出力先になるIO のサブクラスのインスタンスです。
@param format フ......011 ' 123'"
printf("%1$*2$s %2$d %1$s", "hello", 8) #=> " hello 8 hello"
printf("%1$*2$s %2$d", "hello", -8) #=> "hello -8"
printf("%+g:% g:%-g", 1.23, 1.23, 1.23) #=> "+1.23: 1.23:1.23"
printf("%u", -123) #=> "..4294967173"
//}
@see Kernel.#sprintf,IO#printf... -
Kernel
. # printf(port , format , *arg) -> nil (18304.0) -
C 言語の printf と同じように、format に従い引数を文字列に変 換して port に出力します。
...out に出力します。
引数を 1 つも指定しなければ何もしません。
Ruby における format 文字列の拡張については
Kernel.#sprintfの項を参照してください。
@param port 出力先になるIO のサブクラスのインスタンスです。
@param format フ......011 ' 123'"
printf("%1$*2$s %2$d %1$s", "hello", 8) #=> " hello 8 hello"
printf("%1$*2$s %2$d", "hello", -8) #=> "hello -8"
printf("%+g:% g:%-g", 1.23, 1.23, 1.23) #=> "+1.23: 1.23:1.23"
printf("%u", -123) #=> "..4294967173"
//}
@see Kernel.#sprintf,IO#printf...