種類
- モジュール関数 (12)
- インスタンスメソッド (3)
- 変数 (3)
キーワード
-
$ ERROR _ INFO (1) -
$ ERROR _ POSITION (1) -
$ FILENAME (1) - DelegateClass (1)
- String (1)
- autoload (1)
- autoload? (1)
- fail (3)
-
global
_ variables (1) -
local
_ variables (1) - raise (3)
-
set
_ trace _ func (1) - timeout (2)
検索結果
先頭5件
-
Kernel
# DelegateClass(superclass) -> object (37276.0) -
クラス superclass のインスタンスへメソッドを委譲するクラスを定義し、 そのクラスを返します。
クラス superclass のインスタンスへメソッドを委譲するクラスを定義し、
そのクラスを返します。
@param superclass 委譲先となるクラス
例:
//emlist{
require 'delegate'
class ExtArray < DelegateClass(Array)
def initialize
super([])
end
end
a = ExtArray.new
p a.class # => ExtArray
a.push 25
p a # => [25]
//} -
Kernel
# timeout(sec , exception _ class = nil) {|i| . . . . } -> object (682.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
ブロックを sec 秒の期限付きで実行します。
ブロックの実行時間が制限を過ぎたときは例外
Timeout::Error が発生します。
exception_class を指定した場合には Timeout::Error の代わりに
その例外が発生します。
ブロックパラメータ i は sec がはいります。
また sec が 0 もしくは nil のときは制限時間なしで
ブロックを実行します。
@param sec タイムアウトする時間を秒数で指定します.
@param exception_class タイムアウトした時、発生させる例外を指定します.
=== 注意
timeout に... -
Kernel
. # set _ trace _ func(proc) -> Proc (364.0) -
Ruby インタプリタのイベントをトレースする Proc オブジェクトとして 指定された proc を登録します。 nil を指定するとトレースがオフになります。
...uby]{
set_trace_func lambda {|*arg|
p arg
}
class Foo
end
43.to_s
# ----結果----
# ["c-return", "..", 1, :set_trace_func, #<Binding:0xf6ceb8>, Kernel]
# ["line", "..", 4, nil, #<Binding:0x10cbcd8>, nil]
# ["c-call", "..", 4, :inherited, #<Binding:0x10cba98>, Class]
# ["c-return", "..", 4, :inhe......["class", "..", 4, nil, #<Binding:0x10cb600>, nil]
# ["end", "..", 5, nil, #<Binding:0x10cb3f0>, nil]
# ["line", "..", 6, nil, #<Binding:0x10cb1e0>, nil]
# ["c-call", "..", 6, :to_s, #<Binding:0x10cafd0>, Fixnum]
# ["c-return", "..", 6, :to_s, #<Binding:0x10cad78>, Fixnum]
//}
@see Kernel.#caller... -
Kernel
. # autoload?(const _ name) -> String | nil (112.0) -
const_name が Kernel.#autoload 設定されているか調べます。
...const_name が Kernel.#autoload 設定されているか調べます。
autoload 設定されていて、autoload 定数がまだ定義されてない(ロードされていない)
ときにそのパス名を返します。
autoload 設定されていないか、ロード済みなら nil を返し......lass Foo
class Bar
end
end
# ----- end of /tmp/foo.rb ----
class Foo
end
p Foo.autoload?(:Bar) #=> nil
Foo.autoload :Bar, '/tmp/foo'
p Foo.autoload?(:Bar) #=> "/tmp/foo"
p Foo::Bar #=> Foo::Bar
p Foo.autoload?(:Bar) #=> nil
//}
@see Kernel.#autoload... -
Kernel
$ $ FILENAME -> String (100.0) -
仮想ファイル Object::ARGF で現在読み込み中のファイル名です。 ARGF.class#filename と同じです。
仮想ファイル Object::ARGF で現在読み込み中のファイル名です。
ARGF.class#filename と同じです。
この変数はグローバルスコープです。 -
Kernel
# timeout(sec) {|i| . . . . } -> object (82.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
ブロックを sec 秒の期限付きで実行します。
ブロックの実行時間が制限を過ぎたときは例外
Timeout::Error が発生します。
exception_class を指定した場合には Timeout::Error の代わりに
その例外が発生します。
ブロックパラメータ i は sec がはいります。
また sec が 0 もしくは nil のときは制限時間なしで
ブロックを実行します。
@param sec タイムアウトする時間を秒数で指定します.
@param exception_class タイムアウトした時、発生させる例外を指定します.
=== 注意
timeout に... -
Kernel
$ $ ERROR _ INFO -> Exception | nil (40.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 (40.0) -
$@ の別名
$@ の別名
require "English"
class SomethingError < StandardError; end
begin
raise SomethingError
rescue
p $ERROR_POSITION #=> ["sample.rb:5"]
end -
Kernel
. # String(arg) -> String (40.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
. # autoload(const _ name , feature) -> nil (40.0) -
定数 const_name を最初に参照した時に feature を Kernel.#require するように設定します。
...定数 const_name を最初に参照した時に feature を
Kernel.#require するように設定します。
const_name には、 "::" 演算子を含めることはできません。
ネストした定数を指定する方法は Module#autoload を参照してください。
const_name が aut......対象を指定します。
@raise LoadError featureのロードに失敗すると発生します。
//emlist[][ruby]{
# ------- /tmp/foo.rb ---------
class Bar
end
# ----- end of /tmp/foo.rb ----
autoload :Bar, '/tmp/foo'
p Bar #=> Bar
//}
@see Kernel.#autoload?,Module#autoload,Kernel.#require... -
Kernel
. # fail -> () (40.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(error _ type , message = nil , backtrace = caller(0) , cause: $ !) -> () (40.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: $ !) -> () (40.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] (40.0) -
プログラム中で定義されているグローバル変数(`$'で始まる変数)名の 配列を返します。
...グラム中で定義されているグローバル変数(`$'で始まる変数)名の
配列を返します。
//emlist[例][ruby]{
p global_variables #=> [:$;, :$-F, :$@, ... ]
//}
@see Kernel.#local_variables,Object#instance_variables,Module.constants,Module#constants,Module#class_variables... -
Kernel
. # local _ variables -> [Symbol] (40.0) -
現在のスコープで定義されているローカル変数名の配列を返します。
...現在のスコープで定義されているローカル変数名の配列を返します。
//emlist[例][ruby]{
yuyu = 0
p local_variables #=> [:yuyu]
//}
@see Kernel.#global_variables,Object#instance_variables,Module.constants,Module#constants,Module#class_variables... -
Kernel
. # raise -> () (40.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
. # raise(error _ type , message = nil , backtrace = caller(0) , cause: $ !) -> () (40.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
. # raise(message , cause: $ !) -> () (40.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...