るりまサーチ

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

別のキーワード

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

モジュール

オブジェクト

キーワード

検索結果

<< < 1 2 3 4 ... > >>

NoMatchingPatternError (20002.0)

パターンマッチでどの条件にも一致せず、else節もない場合に発生します。

...パターンマッチでどの条件にも一致せず、else節もない場合に発生します。...

ZeroDivisionError (20002.0)

整数に対して整数の 0 で除算を行ったときに発生します。

整数に対して整数の 0 で除算を行ったときに発生します。

Encoding::Converter.asciicompat_encoding(encoding) -> Encoding | nil (17302.0)

同じ文字集合を持つ ASCII 互換エンコーディングを返します。

...集合を持つ ASCII 互換エンコーディングを返します。

@param string エンコーディング名
@param encoding エンコーディングオブジェクト
@return ASCII 互換エンコーディングのオブジェクトか nil

引数とエンコーディングと同じ文字集...
...ングでない場合は nil を返します。

//emlist[][ruby]{
E
ncoding::Converter.asciicompat_encoding("ISO-2022-JP") #=> #<Encoding:stateless-ISO-2022-JP>
E
ncoding::Converter.asciicompat_encoding("UTF-16BE") #=> #<Encoding:UTF-8>
E
ncoding::Converter.asciicompat_encoding("UTF-8") #=> nil
//}...

Numeric#coerce(other) -> [Numeric] (17302.0)

自身と other が同じクラスになるよう、自身か other を変換し [other, self] という配列にして返します。

...自身と other が同じクラスになるよう、自身か other を変換し [other, self] という配列にして返します。

デフォルトでは self と other を Float に変換して [other, self] という配列にして返します。
Numeric のサブクラスは、このメソ...
...erce のソースです。other が自身の知らない数値クラスであった場合、
super を呼んでいることに注意して下さい。


//emlist[例][ruby]{
# lib/rational.rb より

def coerce(other)
if other.kind_of?(Float)
return other, self.to_f
e
lsif other.kind_of?(Inte...
...ger)
return Rational.new!(other, 1), self
e
lse
super
e
nd
e
nd
//}

数値クラスの算術演算子は通常自分と演算できないクラスをオペランドとして受け
取ると coerce を使って自分とオペランドを変換した上で演算を行います。
以下は R...

Object#singleton_method(name) -> Method (17302.0)

オブジェクトの特異メソッド name をオブジェクト化した Method オブ ジェクトを返します。

...name をオブジェクト化した Method オブ
ジェクトを返します。

@param name メソッド名をSymbol またはStringで指定します。
@raise NameError 定義されていないメソッド名を引数として与えると発生します。

//emlist[][ruby]{
class Demo
def in...
...e(n)
@iv = n
e
nd
def hello()
"Hello, @iv = #{@iv}"
e
nd
e
nd

k = Demo.new(99)
def k.hi
"Hi, @iv = #{@iv}"
e
nd
m = k.singleton_method(:hi) # => #<Method: #<Demo:0xf8b0c3c4 @iv=99>.hi>
m.call #=> "Hi, @iv = 99"
m = k.singleton_method(:hello) # => NameError
//}

@see Module#instance...
..._method, Method, BasicObject#__send__, Object#send, Kernel.#eval, Object#method...

絞り込み条件を変える

Exception.exception(error_message = nil) -> Exception (17238.0)

例外オブジェクトを生成して返します。

...@param error_message エラーメッセージを表す文字列を指定します。このメッセージは
属性 Exception#message の値になり、デフォルトの例外ハンドラで表示されます。

//emlist[例][ruby]{
e
= Exception.new("some message")
p e...
...# => #<Exception: some message>
p e.message # => "some message"
//}

//emlist[例][ruby]{
e
= Exception.exception("some message")
p e # => #<Exception: some message>
p e.message # => "some message"
//}...

Exception#exception(error_message) -> Exception (17214.0)

引数を指定しない場合は self を返します。引数を指定した場合 自身のコピー を生成し Exception#message 属性を error_message にして返します。

...合は self を返します。引数を指定した場合 自身のコピー
を生成し Exception#message 属性を error_message にして返します。

Kernel.#raise は、実質的に、例外オブジェクトの exception
メソッドの呼び出しです。

@param error_message エラー...
...メッセージを表す文字列を指定します。

//emlist[例][ruby]{
begin
# ... # 何か処理
rescue => e
raise e.exception("an error occurs during hogehoge process") # 詳しいエラーメッセージ
e
nd
//}...

Thread.report_on_exception -> bool (17214.0)

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

...を $stderr に報告します。

デフォルトは false です。

Thread.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'

これによってスレッドのエラーを早期に捕捉できるようになります。
いくつかのケースでは、この出力を望まないかもしれません。
出力を抑制するには複数の方法があります:

* 例外が...
...で rescue して、
その例外でスレッドが終了しないようにするのがより良い方法です。
* Thread#join や Thread#value でそのスレッドの終了を待つことが保証できるなら、
スレッド開始時に Thread.current.report_on_exception = false でレ...
...容を $stderr に報告します。

デフォルトは true です。

Thread.new { 1.times { raise } }

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

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

これによってスレッドのエラーを早期に捕捉できるようになります。
いくつかのケースでは、この出力を望まないかもしれません。
出力を抑制するには複数の方法があります:

* 例外が...

Thread.report_on_exception=(newstate) (17214.0)

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

...を $stderr に報告します。

デフォルトは false です。

Thread.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'

これによってスレッドのエラーを早期に捕捉できるようになります。
いくつかのケースでは、この出力を望まないかもしれません。
出力を抑制するには複数の方法があります:

* 例外が...
...で rescue して、
その例外でスレッドが終了しないようにするのがより良い方法です。
* Thread#join や Thread#value でそのスレッドの終了を待つことが保証できるなら、
スレッド開始時に Thread.current.report_on_exception = false でレ...
...容を $stderr に報告します。

デフォルトは true です。

Thread.new { 1.times { raise } }

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

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

これによってスレッドのエラーを早期に捕捉できるようになります。
いくつかのケースでは、この出力を望まないかもしれません。
出力を抑制するには複数の方法があります:

* 例外が...

BasicObject#singleton_method_added(name) -> object (17202.0)

特異メソッドが追加された時にインタプリタから呼び出されます。

...Module#method_addedを使います。

@param name 追加されたメソッド名が Symbol で渡されます。

//emlist[例][ruby]{
class Foo
def singleton_method_added(name)
puts "singleton method \"#{name}\" was added"
e
nd
e
nd

obj = Foo.new
def obj.foo
e
nd

#=> singleton method "foo"...
...was added
//}

@see Module#method_added,BasicObject#singleton_method_removed,BasicObject#singleton_method_undefined...

絞り込み条件を変える

BasicObject#singleton_method_removed(name) -> object (17202.0)

特異メソッドが Module#remove_method に より削除された時にインタプリタから呼び出されます。

...ドが Module#remove_method に
より削除された時にインタプリタから呼び出されます。

通常のメソッドの削除に対するフックには
Module#method_removedを使います。

@param name 削除されたメソッド名が Symbol で渡されます。

//emlist[例][ru...
...def singleton_method_removed(name)
puts "singleton method \"#{name}\" was removed"
e
nd
e
nd

obj = Foo.new
def obj.foo
e
nd

class << obj
remove_method :foo
e
nd

#=> singleton method "foo" was removed
//}

@see Module#method_removed,BasicObject#singleton_method_added,BasicObject#singleton_met...
...hod_undefined...
<< < 1 2 3 4 ... > >>