るりまサーチ

最速Rubyリファレンスマニュアル検索!
216件ヒット [1-100件を表示] (0.156秒)

別のキーワード

  1. openssl t61string
  2. asn1 t61string
  3. matrix t
  4. t61string new
  5. fiddle type_size_t

ライブラリ

キーワード

検索結果

<< 1 2 3 > >>

Kernel.#__method__ -> Symbol | nil (12208.0)

現在のメソッド名を返します。 メソッドの外で呼ばれると nil を返します。

...のメソッド名を返します。
メソッドの外で呼ばれると nil を返します。

//emlist[例][ruby]{
def foo
p __method__
end
alias :bar :foo
foo #=> :foo
bar #=> :foo
p __method__ #=> nil
//}

現在のメソッド名が alias されたメソッドの場合でも alias 元のメ...

Kernel.#catch {|tag| .... } -> object (12208.0)

Kernel.#throwとの組み合わせで大域脱出を行います。 catch はブロックを実行します。

...
Kernel
.#throwとの組み合わせで大域脱出を行います。 catch はブロックを実行します。

ブロックの実行中に tag と同一のオブジェクトを引数とする Kernel.#throw が行われた
場合は、その throw の第二引数を戻り値として、ブロック...
...、ブロックパラメータ tag に
渡されます。

@param tag タグとなる任意のオブジェクトです。
@return ブロックの返り値か、対応するthrowの第二引数を返り値として返します。

//emlist[例][ruby]{
result = catch do |tag|
for i in 1..2
for j...
...in 1..2
for k in 1..2
throw tag, k
end
end
end
end

p result #=> 1
//}

@see Kernel.#throw...

Kernel.#catch(tag) {|tag| .... } -> object (12208.0)

Kernel.#throwとの組み合わせで大域脱出を行います。 catch はブロックを実行します。

...
Kernel
.#throwとの組み合わせで大域脱出を行います。 catch はブロックを実行します。

ブロックの実行中に tag と同一のオブジェクトを引数とする Kernel.#throw が行われた
場合は、その throw の第二引数を戻り値として、ブロック...
...、ブロックパラメータ tag に
渡されます。

@param tag タグとなる任意のオブジェクトです。
@return ブロックの返り値か、対応するthrowの第二引数を返り値として返します。

//emlist[例][ruby]{
result = catch do |tag|
for i in 1..2
for j...
...in 1..2
for k in 1..2
throw tag, k
end
end
end
end

p result #=> 1
//}

@see Kernel.#throw...

Kernel.#throw(tag, value = nil) -> () (12208.0)

Kernel.#catchとの組み合わせで大域脱出を行います。 throw は同じ tag を指定した catch のブロックの終わりまでジャンプします。

...
Kernel
.#catchとの組み合わせで大域脱出を行います。 throw
は同じ tag を指定した catch のブロックの終わりまでジャンプします。

t
hrow は探索時に呼び出しスタックをさかのぼるので、
ジャンプ先は同じメソッド内にあるとは限...
...同じ tag で待っている catch が存在しない場合は、例外で
スレッドが終了します。

同じ tag であるとは Object#object_id が同じであるという意味です。

@param tag catch の引数に対応する任意のオブジェクトです。
@param value catch...
...ArgumentError 同じ tag で待っている catch が存在しない場合に発生します。

//emlist[例][ruby]{
def foo
t
hrow :exit, 25
end

ret = catch(:exit) do
begin
foo
some_process() # 絶対に実行されない
10
ensure
puts "ensure"
end
end
puts ret
#=> ens...
...ncaughtThrowError 同じ tag で待っている catch が存在しない場合に発生します。

//emlist[例][ruby]{
def foo
t
hrow :exit, 25
end

ret = catch(:exit) do
begin
foo
some_process() # 絶対に実行されない
10
ensure
puts "ensure"
end
end
puts ret
#=>...

Kernel.#trace_var(varname, hook) -> [String|Proc] (6314.0)

グローバル変数 varname への代入のフックを登録します。

...、特殊変数
(d:spec/variables#builtin を参照)も含めた `$' で始まる変数のこ
とです。

この呼び出し以降、varname で指定したグローバル変数に
値が代入されるたびに hook かブロックが評価されます。hook が Proc オブジェクトの場合...
...字列の場合はRubyコードとして評価されます。

t
race_var がフックするのは明示的な代入だけです。
フックは複数登録できます。

フックを解除するには、hook に nil を
指定するか、Kernel.#untrace_var を用います。

h
ook が nil なら...
...れていた
h
ook をすべて解除してその配列を返します(ブロックで登録されていれば
Proc オブジェクトで返されます)
それ以外は、nil を返します。

@param varname グローバル変数名を文字列か Symbol で指定します。
@param hook フック...

絞り込み条件を変える

Kernel.#caller_locations(range) -> [Thread::Backtrace::Location] | nil (6308.0)

現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。

...現在のフレームを Thread::Backtrace::Location の配列で返します。引
数で指定した値が範囲外の場合は nil を返します。

@param start 開始フレームの位置を数値で指定します。

@param length 取得するフレームの個数を指定します。

@pa...
...mlist[例][ruby]{
def test1(start, length)
locations = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end

def test2(start, length)
t
est1(start, length)
end

def test3(start, length)
t
est2(start, length)
end

caller_locations # => []
t
est3(1...
.../Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'", "/Users/user/test.rb:17:in `<main>'"]
# => [9, 13, 17]
# => ["/Users/user/test.rb", "/Users/user/test.rb", "/Users/user/test.rb"]
t
est3(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9...

Kernel.#caller_locations(start = 1, length = nil) -> [Thread::Backtrace::Location] | nil (6308.0)

現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。

...現在のフレームを Thread::Backtrace::Location の配列で返します。引
数で指定した値が範囲外の場合は nil を返します。

@param start 開始フレームの位置を数値で指定します。

@param length 取得するフレームの個数を指定します。

@pa...
...mlist[例][ruby]{
def test1(start, length)
locations = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end

def test2(start, length)
t
est1(start, length)
end

def test3(start, length)
t
est2(start, length)
end

caller_locations # => []
t
est3(1...
.../Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'", "/Users/user/test.rb:17:in `<main>'"]
# => [9, 13, 17]
# => ["/Users/user/test.rb", "/Users/user/test.rb", "/Users/user/test.rb"]
t
est3(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9...

Kernel.#untrace_var(varname, hook = nil) -> [String|Proc] (6308.0)

グローバル変数 varname に関連付けられたフックを解除します。

...解除します。

h
ook が指定された場合にはそのフックだけを解除します。
省略するか nil を与えた場合は
varname のフックを全て解除します。

@param varname グローバル変数名を文字列か Symbol で指定します。
@param hook 文字列また...
...
@return 解除されたフックの配列を返します。

//emlist[例][ruby]{
t
race_var(:$v){|val| print "hookA.#{val.inspect},\n" }
block = proc{|val| print "hookB.#{val.inspect}," }
t
race_var(:$v,&block)
$v = 'str' #=> hookB."str",hookA."str",

untrace_var(:$v,block)
$v = 'str'...
...#=> hookA."str",

t
race_var(:$v){|val| print "hookC.#{val.inspect}," }
p untrace_var(:$v) #=> [#<Proc:0x02b68f58@..:9>, #<Proc:0x02b6978c@..:3>]
$v = 'str' # なにも出力されない
//}

@see Kernel.#trace_var...

Kernel.#format(format, *arg) -> String (6306.0)

format 文字列を C 言語の sprintf と同じように解釈し、 引数をフォーマットした文字列を返します。

...ormat 文字列を C 言語の sprintf と同じように解釈し、
引数をフォーマットした文字列を返します。

@param format フォーマット文字列です。
@param arg フォーマットされる引数です。
@see Kernel.#printf,Time#strftime,Date.strptime

=== sprintf...
...フォーマット

Ruby
の sprintf フォーマットは基本的に C 言語の sprintf(3)
のものと同じです。ただし、short や long などの C 特有の型に対する修飾子が
ないこと、2進数の指示子(%b, %B)が存在すること、sprintf のすべての方言をサ...
...ポートしていないこと(%': 3桁区切り)などの違いがあります。

Ruby
には整数の大きさに上限がないので、%b, %B, %o, %x, %X
に負の数を与えると (左側に無限に1が続くとみなせるので)
..f のような表示をします。絶対値に符号を付...
<< 1 2 3 > >>