るりまサーチ

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

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method new
  4. irb/input-method gets
  5. matrix -

種類

ライブラリ

キーワード

検索結果

Kernel.#set_trace_func(proc) -> Proc (6280.0)

Ruby インタプリタのイベントをトレースする Proc オブジェクトとして 指定された proc を登録します。 nil を指定するとトレースがオフになります。

..."call": メソッドの呼び出し。
"return": メソッド呼び出しからのリターン。
"c-call": Cで記述されたメソッドの呼び出し。
"c-return": Cで記述されたメソッド呼び出しからのリターン。
"class": クラス定義、特異...
...st[例][ruby]{
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", "..",...
...["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$$-I -> [String] (6161.0)

Rubyライブラリをロードするときの検索パスです。

...リをロードするときの検索パスです。

Kernel
.#load や Kernel.#require
がファイルをロードする時に検索するディレクトリのリストを含む配列です。

起動時にはコマンドラインオプション -I で指定したディレクトリ、
環境変数 RU...
...指定したデフォルト値
をこの順番で含みます。

以下に典型的な UNIX システム上でのロードパスを示します。

-
I で指定したパス
環境変数 RUBYLIB の値
/usr/local/lib/ruby/site_ruby/VERSION サイト固有、バージョン依存のラ...
...ruby -e 'puts $:'

とします。

$LOAD_PATH の特異メソッドとして resolve_feature_path が定義されています。
require を呼んだときに読み込まれるファイルを特定できます。

//emlist[][ruby]{
p $LOAD_PATH.resolve_feature_path('set')
# => [:rb, "/build-all-rub...

Kernel$$: -> [String] (3161.0)

Rubyライブラリをロードするときの検索パスです。

...リをロードするときの検索パスです。

Kernel
.#load や Kernel.#require
がファイルをロードする時に検索するディレクトリのリストを含む配列です。

起動時にはコマンドラインオプション -I で指定したディレクトリ、
環境変数 RU...
...指定したデフォルト値
をこの順番で含みます。

以下に典型的な UNIX システム上でのロードパスを示します。

-
I で指定したパス
環境変数 RUBYLIB の値
/usr/local/lib/ruby/site_ruby/VERSION サイト固有、バージョン依存のラ...
...ruby -e 'puts $:'

とします。

$LOAD_PATH の特異メソッドとして resolve_feature_path が定義されています。
require を呼んだときに読み込まれるファイルを特定できます。

//emlist[][ruby]{
p $LOAD_PATH.resolve_feature_path('set')
# => [:rb, "/build-all-rub...

Kernel$$LOAD_PATH -> [String] (3161.0)

Rubyライブラリをロードするときの検索パスです。

...リをロードするときの検索パスです。

Kernel
.#load や Kernel.#require
がファイルをロードする時に検索するディレクトリのリストを含む配列です。

起動時にはコマンドラインオプション -I で指定したディレクトリ、
環境変数 RU...
...指定したデフォルト値
をこの順番で含みます。

以下に典型的な UNIX システム上でのロードパスを示します。

-
I で指定したパス
環境変数 RUBYLIB の値
/usr/local/lib/ruby/site_ruby/VERSION サイト固有、バージョン依存のラ...
...ruby -e 'puts $:'

とします。

$LOAD_PATH の特異メソッドとして resolve_feature_path が定義されています。
require を呼んだときに読み込まれるファイルを特定できます。

//emlist[][ruby]{
p $LOAD_PATH.resolve_feature_path('set')
# => [:rb, "/build-all-rub...

Kernel$$@ -> [String] | nil (107.0)

最後に例外が発生した時のバックトレースを表す配列です。 Kernel.#raise によって設定されます。

...トレースを表す配列です。
Kernel
.#raise によって設定されます。

配列の各要素はメソッドの呼び出し位置を示す文字列で形式は

"filename:line"

または

"filename:line:in `methodname'"

です。これは Kernel.#caller が返す値と同じ形式...
...するときは、$! が nil であってはいけません。
$@ の値は、$!.backtrace の値と同じです。
また、$@ への代入は $!.set_backtrace 呼び出しと同じです。

文字列の配列でも nil でもない値を代入しようとすると、 TypeError 例外が発生し...

絞り込み条件を変える

Kernel.#caller(range) -> [String] | nil (107.0)

start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。

...

@see Kernel.#set_trace_func,Kernel.#raise,
Kernel
.#caller_locations

//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end

def bar
foo
end

bar

#=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in `<main>'"]
# ["-:10:in `bar'", "-:13:in `<ma...
...in>'"]
# ["-:13:in `<main>'"]
# []
# nil
//}

以下の関数は、caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。

//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
met...
...ler.first)

#=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}

以下は、$DEBUG が真の場合に役に立つ debug 関数
のサンプルです。

//emlist[例][ruby]{
$DEBUG = true

def debug(*args)
p [caller.first, *args] if $DEBUG
end

debug "debug information"

#=> ["-:7", "debug inform...

Kernel.#caller(start = 1) -> [String] | nil (107.0)

start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。

...

@see Kernel.#set_trace_func,Kernel.#raise,
Kernel
.#caller_locations

//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end

def bar
foo
end

bar

#=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in `<main>'"]
# ["-:10:in `bar'", "-:13:in `<ma...
...in>'"]
# ["-:13:in `<main>'"]
# []
# nil
//}

以下の関数は、caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。

//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
met...
...ler.first)

#=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}

以下は、$DEBUG が真の場合に役に立つ debug 関数
のサンプルです。

//emlist[例][ruby]{
$DEBUG = true

def debug(*args)
p [caller.first, *args] if $DEBUG
end

debug "debug information"

#=> ["-:7", "debug inform...

Kernel.#caller(start, length) -> [String] | nil (107.0)

start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。

...

@see Kernel.#set_trace_func,Kernel.#raise,
Kernel
.#caller_locations

//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end

def bar
foo
end

bar

#=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in `<main>'"]
# ["-:10:in `bar'", "-:13:in `<ma...
...in>'"]
# ["-:13:in `<main>'"]
# []
# nil
//}

以下の関数は、caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。

//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
met...
...ler.first)

#=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}

以下は、$DEBUG が真の場合に役に立つ debug 関数
のサンプルです。

//emlist[例][ruby]{
$DEBUG = true

def debug(*args)
p [caller.first, *args] if $DEBUG
end

debug "debug information"

#=> ["-:7", "debug inform...