るりまサーチ (Ruby 2.6.0)

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

モジュール

キーワード

検索結果

<< < ... 17 18 19 >>

TracePoint#eval_script -> String | nil (24010.0)

script_compiledイベント発生時にコンパイルされたソースコードを返します。 ファイルから読み込んだ場合は、nilを返します。

script_compiledイベント発生時にコンパイルされたソースコードを返します。
ファイルから読み込んだ場合は、nilを返します。

//emlist[例][ruby]{
TracePoint.new(:script_compiled) do |tp|
p tp.eval_script # => "puts 'hello'"
end.enable do
eval("puts 'hello'")
end
//}

@raise RuntimeError :script_compiled イベントのための
イベントフックの外側で実行した場合に...

TracePoint#event -> Symbol (24010.0)

発生したイベントの種類を Symbol で返します。

発生したイベントの種類を Symbol で返します。

発生するイベントの詳細については、TracePoint.new を参照してくださ
い。

@raise RuntimeError イベントフックの外側で実行した場合に発生します。

//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call, :return) do |tp|
p tp.event
end
trace.enable
foo 1
# => :call
# :return
//}

TracePoint#inspect -> String (24010.0)

self の状態を人間に読みやすい文字列にして返します。

self の状態を人間に読みやすい文字列にして返します。

//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call) do |tp|
p tp.inspect # "#<TracePoint:call `foo'@/path/to/test.rb:1>"
end
trace.enable
foo 1
//}

TracePoint#instruction_sequence -> RubyVM::InstructionSequence (24010.0)

script_compiledイベント発生時にコンパイルされた RubyVM::InstructionSequenceインスタンスを返します。

script_compiledイベント発生時にコンパイルされた
RubyVM::InstructionSequenceインスタンスを返します。

//emlist[例][ruby]{
TracePoint.new(:script_compiled) do |tp|
p tp.instruction_sequence # => <RubyVM::InstructionSequence:block in <main>@(eval):1>
end.enable do
eval("puts 'hello'")
end
//}

@raise RuntimeError :script_comp...

TracePoint#lineno -> Integer (24010.0)

発生したイベントの行番号を返します。

発生したイベントの行番号を返します。

@raise RuntimeError イベントフックの外側で実行した場合に発生します。

//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call, :return) do |tp|
tp.lineno
end
trace.enable
foo 1
# => 1
# 3
//}

絞り込み条件を変える

TracePoint#method_id -> Symbol | nil (24010.0)

イベントが発生したメソッドの定義時の名前を Symbol で返します。 トップレベルであった場合は nil を返します。

イベントが発生したメソッドの定義時の名前を Symbol で返します。
トップレベルであった場合は nil を返します。

@raise RuntimeError イベントフックの外側で実行した場合に発生します。

//emlist[][ruby]{
class C
def method_name
end
alias alias_name method_name
end

trace = TracePoint.new(:call) do |tp|
p [tp.method_id, tp.callee_id] # => [:method_name, :alias_name]
e...

TracePoint#parameters -> [object] (24010.0)

現在のフックが属するメソッドまたはブロックのパラメータ定義を返します。 フォーマットは Method#parameters と同じです。

現在のフックが属するメソッドまたはブロックのパラメータ定義を返します。
フォーマットは Method#parameters と同じです。

@raise RuntimeError :call、:return、:b_call、:b_return、:c_call、:c_return
イベントのためのイベントフックの外側で実行した場合に発生します。

//emlist[例][ruby]{
def foo(a, b = 2)
end
TracePoint.new(:call) do |tp|
p tp.parameters # => a], [:opt, ...

TracePoint#path -> String (24010.0)

イベントが発生したファイルのパスを返します。

イベントが発生したファイルのパスを返します。

@raise RuntimeError イベントフックの外側で実行した場合に発生します。

//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call) do |tp|
p tp.path # => "/path/to/test.rb"
end
trace.enable
foo 1
//}

TracePoint#raised_exception -> Exception (24010.0)

発生した例外を返します。

発生した例外を返します。

@raise RuntimeError :raise イベントのためのイベントフックの外側で実行し
た場合に発生します。

//emlist[例][ruby]{
trace = TracePoint.new(:raise) do |tp|
tp.raised_exception # => #<ZeroDivisionError: divided by 0>
end
trace.enable
begin
0/0
rescue
end
//}

TracePoint#return_value -> object (24010.0)

メソッドやブロックの戻り値を返します。

メソッドやブロックの戻り値を返します。

@raise RuntimeError :return、:c_return、:b_return イベントのためのイベ
ントフックの外側で実行した場合に発生します。

//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:return) do |tp|
p tp.return_value # => 1
end
trace.enable
foo 1
//}

絞り込み条件を変える

TracePoint#self -> object (24010.0)

イベントを発生させたオブジェクトを返します。

イベントを発生させたオブジェクトを返します。

以下のようにする事で同じ値を取得できます。


//emlist[例][ruby]{
trace.binding.eval('self')
//}

@see TracePoint#binding

TrueClass#&(other) -> bool (24010.0)

other が真なら true を, 偽なら false を返します。

other が真なら true を, 偽なら false を返します。

@param other 論理積を行なう式です。

& は再定義可能な演算子に分類されていますので、通常は true & other のように使われます。

//emlist[例][ruby]{
p true & true #=> true
p true & false #=> false
p true & nil #=> false
p true & (1 == 1) #=> true
p true & (1 + 1) #=> true

p true.&(true) #=> true...

TrueClass#^(other) -> bool (24010.0)

other が真なら false を, 偽なら true を返します。

other が真なら false を, 偽なら true を返します。

@param other 排他的論理和を行なう式です。

^ は再定義可能な演算子に分類されていますので、通常は true ^ other のように使われます。

//emlist[例][ruby]{
p true ^ true #=> false
p true ^ false #=> true
p true ^ nil #=> true
p true ^ (1 == 1) #=> false
p true ^ (1 + 1) #=> false

p true.^(true) #=> ...

TrueClass#inspect -> String (24010.0)

常に文字列 "true" を返します。

常に文字列 "true" を返します。

//emlist[例][ruby]{
true.inspect # => "true"
//}

TrueClass#to_s -> String (24010.0)

常に文字列 "true" を返します。

常に文字列 "true" を返します。

//emlist[例][ruby]{
true.to_s # => "true"
//}

絞り込み条件を変える

TrueClass#|(other) -> bool (24010.0)

常に true を返します。

常に true を返します。

@param other 論理和を行なう式です。

| は再定義可能な演算子に分類されていますので、通常は true | other のように使われます。

//emlist[例][ruby]{
p true | true #=> true
p true | false #=> true
p true | nil #=> true
p true | (1 == 1) #=> true
p true | (1 + 1) #=> true

p true.|(true) #=> true
p true.|(false) #=> ...

UnboundMethod#==(other) -> bool (24010.0)

自身と other が同じクラスあるいは同じモジュールの同じメソッドを表す場合に true を返します。そうでない場合に false を返します。

自身と other が同じクラスあるいは同じモジュールの同じメソッドを表す場合に
true を返します。そうでない場合に false を返します。

@param other 自身と比較したいオブジェクトを指定します。

//emlist[例][ruby]{
a = String.instance_method(:size)
b = String.instance_method(:size)
p a == b #=> true

c = Array.instance_method(:size)
p a == c ...

UnboundMethod#arity -> Integer (24010.0)

メソッドが受け付ける引数の数を返します。

メソッドが受け付ける引数の数を返します。

ただし、メソッドが可変長引数を受け付ける場合、負の整数
-(必要とされる引数の数 + 1)
を返します。C 言語レベルで実装されたメソッドが可変長引数を
受け付ける場合、-1 を返します。

//emlist[例][ruby]{
class C
def one; end
def two(a); end
def three(*a); end
def four(a, b); end
def five(a, b, *c); end
def six(a, b, *c, &d); end
end

p C.insta...

UnboundMethod#bind(obj) -> Method (24010.0)

self を obj にバインドした Method オブジェクトを生成して返します。

self を obj にバインドした Method オブジェクトを生成して返します。


@param obj 自身をバインドしたいオブジェクトを指定します。ただしバインドできるのは、
生成元のクラスかそのサブクラスのインスタンスのみです。

@raise TypeError objがbindできないオブジェクトである場合に発生します

//emlist[例][ruby]{
# クラスのインスタンスメソッドの UnboundMethod の場合
class Foo
def foo
"foo"
end
end

# UnboundMethod `m' を生...

UnboundMethod#clone -> UnboundMethod (24010.0)

自身を複製した UnboundMethod オブジェクトを作成して返します。

自身を複製した UnboundMethod オブジェクトを作成して返します。

//emlist[例][ruby]{
a = String.instance_method(:size)
b = a.clone

a == b # => true
//}

絞り込み条件を変える

UnboundMethod#eql?(other) -> bool (24010.0)

自身と other が同じクラスあるいは同じモジュールの同じメソッドを表す場合に true を返します。そうでない場合に false を返します。

自身と other が同じクラスあるいは同じモジュールの同じメソッドを表す場合に
true を返します。そうでない場合に false を返します。

@param other 自身と比較したいオブジェクトを指定します。

//emlist[例][ruby]{
a = String.instance_method(:size)
b = String.instance_method(:size)
p a == b #=> true

c = Array.instance_method(:size)
p a == c ...

UnboundMethod#hash -> Integer (24010.0)

自身のハッシュ値を返します。

自身のハッシュ値を返します。


//emlist[例][ruby]{
a = method(:==).unbind
b = method(:eql?).unbind
p a.eql? b # => true
p a.hash == b.hash # => true
p [a, b].uniq.size # => 1
//}

UnboundMethod#inspect -> String (24010.0)

self を読みやすい文字列として返します。

self を読みやすい文字列として返します。

詳しくは Method#inspect を参照してください。

//emlist[例][ruby]{
String.instance_method(:count).inspect # => "#<UnboundMethod: String#count>"
//}

@see Method#inspect

UnboundMethod#name -> Symbol (24010.0)

このメソッドの名前を返します。

このメソッドの名前を返します。

//emlist[例][ruby]{
a = String.instance_method(:size)
a.name # => :size
//}

UnboundMethod#original_name -> Symbol (24010.0)

オリジナルのメソッド名を返します。

オリジナルのメソッド名を返します。

//emlist[例][ruby]{
class C
def foo; end
alias bar foo
end
C.instance_method(:bar).original_name # => :foo
//}

@see Method#original_name

絞り込み条件を変える

UnboundMethod#owner -> Class | Module (24010.0)

このメソッドが定義されている class か module を返します。

このメソッドが定義されている class か module を返します。

//emlist[例][ruby]{
Integer.instance_method(:to_s).owner # => Integer
Integer.instance_method(:to_c).owner # => Numeric
Integer.instance_method(:hash).owner # => Kernel
//}

UnboundMethod#parameters -> [object] (24010.0)

UnboundMethod オブジェクトの引数の情報を返します。

UnboundMethod オブジェクトの引数の情報を返します。

詳しくは Method#parameters を参照してください。



@see Proc#parameters, Method#parameters

UnboundMethod#source_location -> [String, Integer] | nil (24010.0)

ソースコードのファイル名と行番号を配列で返します。

ソースコードのファイル名と行番号を配列で返します。

その手続オブジェクトが ruby で定義されていない(つまりネイティブ
である)場合は nil を返します。

//emlist[例][ruby]{
require 'time'

Time.instance_method(:zone).source_location # => nil
Time.instance_method(:httpdate).source_location # => ["/Users/user/.rbenv/versions/2.4.3/lib/ruby/2.4.0/time.rb", 654]
/...

UnboundMethod#super_method -> UnboundMethod | nil (24010.0)

self 内で super を実行した際に実行されるメソッドを UnboundMethod オブジェ クトにして返します。

self 内で super を実行した際に実行されるメソッドを UnboundMethod オブジェ
クトにして返します。


@see Method#super_method

UnboundMethod#to_s -> String (24010.0)

self を読みやすい文字列として返します。

self を読みやすい文字列として返します。

詳しくは Method#inspect を参照してください。

//emlist[例][ruby]{
String.instance_method(:count).inspect # => "#<UnboundMethod: String#count>"
//}

@see Method#inspect

絞り込み条件を変える

UncaughtThrowError#tag -> object (24010.0)

Kernel.#throw に指定した tag を返します。

Kernel.#throw に指定した tag を返します。

//emlist[例:][ruby]{
def do_complicated_things
throw :uncaught_label
end

begin
do_complicated_things
rescue UncaughtThrowError => ex
p ex.tag # => ":uncaught_label"
end
//}

UncaughtThrowError#to_s -> String (24010.0)

self を tag を含む文字列表現にして返します。

self を tag を含む文字列表現にして返します。

//emlist[例][ruby]{
def do_complicated_things
throw :uncaught_label
end

begin
do_complicated_things
rescue UncaughtThrowError => ex
p ex.to_s # => "uncaught throw :uncaught_label"
end
//}

UncaughtThrowError#value -> object (24010.0)

Kernel.#throw に指定した value を返します。

Kernel.#throw に指定した value を返します。

//emlist[例][ruby]{
def do_complicated_things
throw :uncaught_label, "uncaught_value"
end

begin
do_complicated_things
rescue UncaughtThrowError => ex
p ex.value # => "uncaught_value"
end
//}

Warning#warn(message) -> nil (24010.0)

引数 message を標準エラー出力 $stderr に出力します。

引数 message を標準エラー出力 $stderr に出力します。

Kernel.#warnの挙動を変更する際は、このメソッドではなくクラスメソッドであるWarning.warnをオーバーライドする必要があります。

@param message 出力するオブジェクトを指定します。

@param category 警告のカテゴリを指定します。サポートされている category については Warning.[] を参照してください。


@see Kernel.#warn, Warning.warn
<< < ... 17 18 19 >>