るりまサーチ

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

別のキーワード

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

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Enumerator::ArithmeticSequence#begin -> Numeric (35203.0)

初項 (始端) を返します。

...初項 (始端) を返します。

@see Enumerator::ArithmeticSequence#end...

Enumerator::ArithmeticSequence#begin -> Numeric | nil (35203.0)

初項 (始端) を返します。

...初項 (始端) を返します。

@see Enumerator::ArithmeticSequence#end...

MatchData#begin(n) -> Integer | nil (32339.0)

n 番目の部分文字列先頭のオフセットを返します。

...ise IndexError 範囲外の n を指定した場合に発生します。

//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.begin(0) # => 0
p $~.begin(1) # => 0
p $~.begin(2) # => 3
p $~.begin(3) # => nil
p $~.begin(4) # => `begin': index 4 out of matches (IndexError)
//}

@see M...
...atchData#end...

Range#begin -> object (32237.0)

始端の要素を返します。 始端を持たない範囲オブジェクトの場合、begin はnilを返しますが, first は例外 RangeError が発生します。

...begin はnilを返しますが, first は例外 RangeError が発生します。

//emlist[例][ruby]{
# 始端を持つ場合
p (1..5).begin # => 1
p (1..0).begin # => 1
p (1..5).first # => 1
p (1..0).first # => 1

# 始端を持たない場合
p (..5).begin #=> nil
p (..5).first #=> RangeError...
...//}

@see Range#end...

Enumerator::ArithmeticSequence#end -> Numeric | nil (20108.0)

末項(終端)を返します。

...末項(終端)を返します。

@see Enumerator::ArithmeticSequence#begin...

絞り込み条件を変える

Exception#exception(error_message) -> Exception (17220.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
//}...

KeyError#key -> object (17126.0)

KeyError の原因となったメソッド呼び出しのキーを返します。

...KeyError の原因となったメソッド呼び出しのキーを返します。

@raise ArgumentError キーが設定されていない時に発生します。

例:

h = Hash.new
begin

h.fetch('gumby'*20)
rescue KeyError => e
p e.message # => "key not found: \"gumbygumby...
...gumbygumbygumbygumbygumbygumbygumbygumbygumbygumbyg..."
p 'gumby'*20 == e.key # => true
e
nd...

Exception#exception -> self (17120.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
//}...

Encoding::InvalidByteSequenceError#incomplete_input? -> bool (17114.0)

エラー発生時に入力文字列が不足している場合に真を返します。

...//emlist[例][ruby]{
e
c = Encoding::Converter.new("EUC-JP", "ISO-8859-1")

begin

e
c.convert("abc\xA1z")
rescue Encoding::InvalidByteSequenceError
p $!
#=> #<Encoding::InvalidByteSequenceError: "\xA1" followed by "z" on EUC-JP>
p $!.incomplete_input? #=> false
e
nd

begin

e
c.convert("ab...
...c\xA1")
e
c.finish
rescue Encoding::InvalidByteSequenceError
p $! #=> #<Encoding::InvalidByteSequenceError: incomplete "\xA1" on EUC-JP>
p $!.incomplete_input? #=> true
e
nd
//}...

Encoding::InvalidByteSequenceError#error_bytes -> String (17108.0)

エラー発生時に捨てられたバイト列を返します。

.../emlist[例][ruby]{
e
c = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
begin

e
c.convert("abc\xA1\xFFdef")
rescue Encoding::InvalidByteSequenceError
p $!
#=> #<Encoding::InvalidByteSequenceError: "\xA1" followed by "\xFF" on EUC-JP>
puts $!.error_bytes.dump #=> "\xA1"
puts $!.rea...
...dagain_bytes.dump #=> "\xFF"
e
nd
//}

@see Encoding::InvalidByteSequenceError#readagain_bytes...

絞り込み条件を変える

TracePoint#raised_exception -> Exception (17108.0)

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

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

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

0/0
rescue
e
...

KeyError#receiver -> object (14226.0)

KeyError の原因となったメソッド呼び出しのレシーバを返します。

...KeyError の原因となったメソッド呼び出しのレシーバを返します。

@raise ArgumentError レシーバが設定されていない時に発生します。

例:

h = Hash.new
begin

h.fetch('gumby'*20)
rescue KeyError => e
p e.message # => "key not found:...
...\"gumbygumbygumbygumbygumbygumbygumbygumbygumbygumbygumbygumbyg..."
p h.equal?(e.receiver) # => true
e
nd...
<< 1 2 3 ... > >>