るりまサーチ

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

別のキーワード

  1. openssl p
  2. openssl p=
  3. fileutils mkdir_p
  4. dsa p
  5. rsa p

クラス

モジュール

キーワード

検索結果

<< 1 2 > >>

Proc#call(*arg) -> () (18221.0)

手続きオブジェクトを実行してその結果を返します。

... Proc#lambda? を参照してください。

「===」は when の所に手続きを渡せるようにするためのものです。

//emlist[例][ruby]{
def sign(n)
case n
when lambda{|n| n > 0} then 1
when lambda{|n| n < 0} then -1
else 0
end
end

p
sign(-4) #=> -1
p
sign(0) #=> 0
p
s...
...when 0 then 0
when 1 then 1
else
fib.(n - 2) + fib.(n - 1)
end
}
fib.(10) # => 55
//}



@param arg 手続きオブジェクトに与える引数を指定します。

@raise LocalJumpError Procを生成したメソッドからリターンしてしまった場合に発生します。...

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

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

...します。caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。

引数で指定した値が範囲外の場合は nil を返します。

@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取...
...ます。

@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

def b...
...caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。

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

def foo
p
parse_caller(...

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

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

...します。caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。

引数で指定した値が範囲外の場合は nil を返します。

@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取...
...ます。

@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

def b...
...caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。

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

def foo
p
parse_caller(...

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

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

...します。caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。

引数で指定した値が範囲外の場合は nil を返します。

@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取...
...ます。

@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

def b...
...caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。

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

def foo
p
parse_caller(...

Thread.report_on_exception -> bool (6126.0)

真の時は、いずれかのスレッドが例外によって終了した時に、その内容を $stderr に報告します。

...ad.new { 1.times { raise } }

は $stderr に以下のように出力します:

#<Thread:...> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
2: from -e:1:in `block in <main>'
1: from -e:1:in `times'

これによってスレッド...
...もしれません。
出力を抑制するには複数の方法があります:

*
例外が意図したものではない場合、原因を修正して例外が発生しないようにする方法が最善です。
*
例外が意図したものの場合、例外が発生する場所により近...
...が終了しないようにするのがより良い方法です。
*
Thread#join や Thread#value でそのスレッドの終了を待つことが保証できるなら、
スレッド開始時に Thread.current.report_on_exception = false でレポートを無効化しても
安全です。...

絞り込み条件を変える

Thread.report_on_exception=(newstate) (6126.0)

真の時は、いずれかのスレッドが例外によって終了した時に、その内容を $stderr に報告します。

...ad.new { 1.times { raise } }

は $stderr に以下のように出力します:

#<Thread:...> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
2: from -e:1:in `block in <main>'
1: from -e:1:in `times'

これによってスレッド...
...もしれません。
出力を抑制するには複数の方法があります:

*
例外が意図したものではない場合、原因を修正して例外が発生しないようにする方法が最善です。
*
例外が意図したものの場合、例外が発生する場所により近...
...が終了しないようにするのがより良い方法です。
*
Thread#join や Thread#value でそのスレッドの終了を待つことが保証できるなら、
スレッド開始時に Thread.current.report_on_exception = false でレポートを無効化しても
安全です。...

Proc#>>(callable) -> Proc (3262.0)

self と引数を合成した Proc を返します。

...合成した Proc を返します。

戻り値の Proc は可変長の引数を受け取ります。
戻り値の Proc を呼び出すと、まず受け取った引数を self に渡して呼び出し、
その戻り値を callable に渡して呼び出した結果を返します。

P
roc#<< とは...
...序が逆になります。

@param callable Proc、Method、もしくは任意の call メソッドを持ったオブジェクト。

//emlist[例][ruby]{
f = proc { |x| x * x }
g = proc { |x| x + x }

# (3 * 3) + (3 * 3)
p
(f >> g).call(3) # => 18
//}

//emlist[call を定義したオブジェク...
...を渡す例][ruby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end
end

File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT

p
ipeline = proc { |fname| File.read(fname) } >> WordScanner >> method(:p)
p
ipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]...

Proc#<<(callable) -> Proc (3250.0)

self と引数を合成した Proc を返します。

...合成した Proc を返します。

戻り値の Proc は可変長の引数を受け取ります。
戻り値の Proc を呼び出すと、まず受け取った引数を callable に渡して呼び出し、
その戻り値を self に渡して呼び出した結果を返します。

P
roc#>> とは...
...序が逆になります。

@param callable Proc、Method、もしくは任意の call メソッドを持ったオブジェクト。

//emlist[例][ruby]{
f = proc { |x| x * x }
g = proc { |x| x + x }

# (3 + 3) * (3 + 3)
p
(f << g).call(3) # => 36
//}

//emlist[call を定義したオブジェク...
...例][ruby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end
end

File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT

p
ipeline = proc { |data| puts "word count: #{data.size}" } << WordScanner << File.method(:read)
p
ipeline.call('testfile') # => word count: 4
//}

@se...

TracePoint.new(*events) {|obj| ... } -> TracePoint (3244.0)

新しい TracePoint オブジェクトを作成して返します。トレースを有効 にするには TracePoint#enable を実行してください。

...い TracePoint オブジェクトを作成して返します。トレースを有効
にするには TracePoint#enable を実行してください。

//emlist[例:irb で実行した場合][ruby]{
trace = TracePoint.new(:call) do |tp|
p
[tp.lineno, tp.defined_class, tp.method_id, tp.event]
end...
...# => #<TracePoint:0x007f17372cdb20>

trace.enable
# => false

p
uts "Hello, TracePoint!"
# ...
# [69, IRB::Notifier::AbstractNotifier, :printf, :call]
# ...
//}

トレースを無効にするには TracePoint#disable を実行してください。

//emlist[][ruby]{
trace.disable
//}

@param events...
...定義、特異クラス定義、モジュール定義の終了。

: :call

Ruby で記述されたメソッドの呼び出し。

: :return

Ruby で記述されたメソッド呼び出しからのリターン。

: :c_call

C で記述されたメソッドの呼び出し。

: :c_return...

TracePoint.trace(*events) {|obj| ... } -> TracePoint (3208.0)

新しい TracePoint オブジェクトを作成して自動的にトレースを開始し ます。TracePoint.new のコンビニエンスメソッドです。

...新しい TracePoint オブジェクトを作成して自動的にトレースを開始し
ます。TracePoint.new のコンビニエンスメソッドです。

@param events トレースするイベントを String か Symbol で任
意の数指定します。指定できる値に...
...ついては
TracePoint.new を参照してください。

//emlist[例][ruby]{
trace = TracePoint.trace(:call) { |tp| [tp.lineno, tp.event] }
# => #<TracePoint:0x007f786a452448>

trace.enabled? # => true
//}

@raise ThreadError ブロックを指定しなかった場合に発生し...

絞り込み条件を変える

Proc#ruby2_keywords -> proc (3146.0)

Marks the proc as passing keywords through a normal argument splat. This should only be called on procs that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the proc such that if the proc is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the proc to other methods.

...e proc as passing keywords through a normal argument splat. This
should only be called on procs that accept an argument splat (`*args`)
but not explicit keywords or a keyword splat. It marks the proc such
that if the proc is called with keyword arguments, the final hash
argument is marked with a sp...
...f a normal argument splat to another method call, and that
method call does not include explicit keywords or a keyword splat, the
final element is interpreted as keywords. In other words, keywords will
be passed through the proc to other methods.

This should only be used for procs that delegate ke...
...and only for backwards compatibility with Ruby versions before
2.7.

This method will probably be removed at some point, as it exists only
for backwards compatibility. As it does not exist in Ruby versions
before 2.7, check that the proc responds to this method before calling
it. Also, be aware tha...

Proc#===(*arg) -> () (3121.0)

手続きオブジェクトを実行してその結果を返します。

... Proc#lambda? を参照してください。

「===」は when の所に手続きを渡せるようにするためのものです。

//emlist[例][ruby]{
def sign(n)
case n
when lambda{|n| n > 0} then 1
when lambda{|n| n < 0} then -1
else 0
end
end

p
sign(-4) #=> -1
p
sign(0) #=> 0
p
s...
...when 0 then 0
when 1 then 1
else
fib.(n - 2) + fib.(n - 1)
end
}
fib.(10) # => 55
//}



@param arg 手続きオブジェクトに与える引数を指定します。

@raise LocalJumpError Procを生成したメソッドからリターンしてしまった場合に発生します。...
<< 1 2 > >>