るりまサーチ

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

別のキーワード

  1. kernel $libs
  2. kernel $ldflags
  3. kernel $kcode
  4. kernel $ofs
  5. kernel $debug

種類

ライブラリ

モジュール

キーワード

検索結果

Kernel$$DEBUG -> bool (42202.0)

この値が真のときはインタプリタがデバッグモードになります。

....abort_on_exception= の効果がなくなります。
* 例外を捕捉しているかどうかに関係なく、
例外が発生した時点で $stderr にそれが出力されます。
スクリプトの処理は続行されます。

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

@s...

Kernel$$-d -> bool (27102.0)

この値が真のときはインタプリタがデバッグモードになります。

....abort_on_exception= の効果がなくなります。
* 例外を捕捉しているかどうかに関係なく、
例外が発生した時点で $stderr にそれが出力されます。
スクリプトの処理は続行されます。

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

@s...

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

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

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

トップレベルでは空の配列を返します。caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。

引数で指定した...
...します。

@param range 取得したいスタックの範囲を示す Range オブジェクトを指定します。

@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

de...
...at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end

def foo
p parse_caller(caller.first)
end

def bar
foo
p parse_caller(caller.first)
end

bar
p parse_caller(caller.first)

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

以下は、$DEBUG が真の場...

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

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

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

トップレベルでは空の配列を返します。caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。

引数で指定した...
...します。

@param range 取得したいスタックの範囲を示す Range オブジェクトを指定します。

@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

de...
...at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end

def foo
p parse_caller(caller.first)
end

def bar
foo
p parse_caller(caller.first)
end

bar
p parse_caller(caller.first)

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

以下は、$DEBUG が真の場...

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

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

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

トップレベルでは空の配列を返します。caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。

引数で指定した...
...します。

@param range 取得したいスタックの範囲を示す Range オブジェクトを指定します。

@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

de...
...at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end

def foo
p parse_caller(caller.first)
end

def bar
foo
p parse_caller(caller.first)
end

bar
p parse_caller(caller.first)

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

以下は、$DEBUG が真の場...

絞り込み条件を変える

irb (132.0)

irb は Interactive Ruby の略です。 irb を使うと、Ruby の式を標準入力から簡単に入力・実行することができます。

...さえ知っていれば irb を使うのは簡単です。
irb コマンドを実行すると、以下のようなプロンプトが表れます。

$
irb
irb(main):001:0>

あとは Ruby の式を入力するだけで、その式が実行され、結果が表示されます。

irb(main):001...
...options:
-f ~/.irbrc を読み込まない
-m bc モード (分数と行列の計算ができる)
-d $DEBUG を true にする (ruby -d と同じ)
-w ruby -w と同じ
-W[level=2] ruby -W と同じ
-r library rub...
...f[:PROMPT_MODE] = :MY_PROMPT

PROMPT_I, PROMPT_S, PROMPT_C にはフォーマット文字列を指定します。
フォーマット文字列では Kernel.#printf のように
「%」を用いた記法が使えます。
フォーマット文字列で使用可能な記法は以下の通りです。...
...のコマンドラインオプション

irb [options] file_name opts
options:
-f ~/.irbrc を読み込まない
-d $DEBUG を true にする (ruby -d と同じ)
-w ruby -w と同じ
-W[level=2] ruby -W と同じ
-r library rub...

制御構造 (54.0)

制御構造 条件分岐: * if * unless * case 繰り返し: * while * until * for * break * next * redo * retry 例外処理: * raise * begin その他: * return * BEGIN * END

...件式が正規表現のリテラルである時には特別に

//emlist[][ruby]{
$
_ =~ リテラル
//}

であるかのように評価されます。

==== if 修飾子

//emlist[例][ruby]{
print "debug\n" if $DEBUG
//}

文法:

式 if 式

右辺の条件が成立する時に、左...
...辺の式を評価してその結果を返します。
条件が成立すれば nil を返します。

====[a:case] case

//emlist[例][ruby]{
case $age
when 0 .. 2
"baby"
when 3 .. 6
"little child"
when 7 .. 12
"child"
when 13 .. 18
"youth"
else
"adult"
end
//}

文法:

case [...
...は第一引数で指定された例外を、第二引数をメッセージとして発生さ
せます。第四の形式の第三引数は
$
@または
Kernel
.#callerで得られる
スタック情報で、例外が発生した場所を示します。

発生した例外は後述の begin 式の res...