るりまサーチ (Ruby 2.6.0)

最速Rubyリファレンスマニュアル検索!
18件ヒット [1-18件を表示] (0.022秒)
トップページ > クエリ:Class[x] > バージョン:2.6.0[x] > モジュール:Kernel[x]

別のキーワード

  1. argf.class lines
  2. argf.class each
  3. argf.class each_line
  4. class new
  5. argf.class gets

検索結果

Kernel#DelegateClass(superclass) -> object (18640.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 (343.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 (184.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 (58.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 (52.0)

仮想ファイル Object::ARGF で現在読み込み中のファイル名です。 ARGF.class#filename と同じです。

仮想ファイル Object::ARGF で現在読み込み中のファイル名です。
ARGF.class#filename と同じです。

この変数はグローバルスコープです。

絞り込み条件を変える

Kernel#timeout(sec) {|i| .... } -> object (43.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 (22.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 (22.0)

$@ の別名

$@ の別名

require "English"
class SomethingError < StandardError; end

begin
raise SomethingError
rescue
p $ERROR_POSITION #=> ["sample.rb:5"]
end

Kernel.#String(arg) -> String (22.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 (22.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 -> () (22.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: $!) -> () (22.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: $!) -> () (22.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] (22.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] (22.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 -> () (22.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: $!) -> () (22.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: $!) -> () (22.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...