るりまサーチ

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

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

キーワード

検索結果

<< 1 2 > >>

Exception#message -> String (18226.0)

エラーメッセージをあらわす文字列を返します。

...エラーメッセージをあらわす文字列を返します。

//emlist[例][ruby]{
begin

1 + nil
r
escue => e
p e.message #=> "nil can't be coerced into Fixnum"
end
//}...

Exception#full_message(highlight: true, order: :bottom) -> String (6250.0)

例外の整形された文字列を返します。

...字列を返します。

返される文字列は Ruby が捕捉されなかった例外を標準エラー出力に出力するときと
同じ形式です。
そのため、メソッド呼び出し時に $stderr が変更されておらず、$stderr.tty? が真の場合は
エスケープシーケ...
...数 highlight と order は 2.5.1 で追加されました。

@param highlight エスケープシーケンスによる文字装飾をつけるかどうかを指定します。
デフォルト値は Exception.to_tty? の返り値と同じです。

@param order :top か :bottom で...
...][ruby]{
begin

r
aise "test"
r
escue => e
p e.full_message # => "\e[1mTraceback \e[m(most recent call last):\ntest.rb:2:in `<main>': \e[1mtest (\e[4;1mRuntimeError\e[m\e[1m)\n\e[m"
$stderr = $stdout
p e.full_message # => "test.rb:2:in `<main>': test (RuntimeError)\n"
$stderr = STDERR
p...
...文字装飾がついています。


@param highlight エスケープシーケンスによる文字装飾をつけるかどうかを指定します。
デフォルト値は Exception.to_tty? の返り値と同じです。

@param order :top か :bottom で指定する必要があ...

Exception#to_s -> String (3126.0)

エラーメッセージをあらわす文字列を返します。

...エラーメッセージをあらわす文字列を返します。

//emlist[例][ruby]{
begin

1 + nil
r
escue => e
p e.message #=> "nil can't be coerced into Fixnum"
end
//}...

Thread::SizedQueue#deq(non_block = false) -> object (3061.0)

キューからひとつ値を取り出します。 キューに push しようと待っているスレッドがあれば、実行を再開させます。

...@param non_block true を与えると、キューが空の時に例外 ThreadError が発生します。

//emlist[例][ruby]{
r
equire 'thread'

q = SizedQueue.new(4)

th1 = Thread.start do
while resource = q.pop
puts resource
end
end

[:resource1, :resource2, :resource3, nil].each{|r|
q...
....push(r)
}

th1.join
# => resource1
# resource2
# resource3
//}

//emlist[例: nonblock = true][ruby]{
r
equire 'thread'

q = SizedQueue.new(4)

th1 = Thread.start do
while resource = q.pop
puts resource
end
end

[:resource1, :resource2, :resource3, nil].each{|r|
q.push(r)
}

begin

th1.jo...
...in
q.pop(true)
r
escue => e
p e
p e.message
end

# => resource1
# resource2
# resource3
# => #<ThreadError: queue empty>
# => "queue empty"
//}

@see Thread::Queue#pop...

Thread::SizedQueue#pop(non_block = false) -> object (3061.0)

キューからひとつ値を取り出します。 キューに push しようと待っているスレッドがあれば、実行を再開させます。

...@param non_block true を与えると、キューが空の時に例外 ThreadError が発生します。

//emlist[例][ruby]{
r
equire 'thread'

q = SizedQueue.new(4)

th1 = Thread.start do
while resource = q.pop
puts resource
end
end

[:resource1, :resource2, :resource3, nil].each{|r|
q...
....push(r)
}

th1.join
# => resource1
# resource2
# resource3
//}

//emlist[例: nonblock = true][ruby]{
r
equire 'thread'

q = SizedQueue.new(4)

th1 = Thread.start do
while resource = q.pop
puts resource
end
end

[:resource1, :resource2, :resource3, nil].each{|r|
q.push(r)
}

begin

th1.jo...
...in
q.pop(true)
r
escue => e
p e
p e.message
end

# => resource1
# resource2
# resource3
# => #<ThreadError: queue empty>
# => "queue empty"
//}

@see Thread::Queue#pop...

絞り込み条件を変える

Thread::SizedQueue#shift(non_block = false) -> object (3061.0)

キューからひとつ値を取り出します。 キューに push しようと待っているスレッドがあれば、実行を再開させます。

...@param non_block true を与えると、キューが空の時に例外 ThreadError が発生します。

//emlist[例][ruby]{
r
equire 'thread'

q = SizedQueue.new(4)

th1 = Thread.start do
while resource = q.pop
puts resource
end
end

[:resource1, :resource2, :resource3, nil].each{|r|
q...
....push(r)
}

th1.join
# => resource1
# resource2
# resource3
//}

//emlist[例: nonblock = true][ruby]{
r
equire 'thread'

q = SizedQueue.new(4)

th1 = Thread.start do
while resource = q.pop
puts resource
end
end

[:resource1, :resource2, :resource3, nil].each{|r|
q.push(r)
}

begin

th1.jo...
...in
q.pop(true)
r
escue => e
p e
p e.message
end

# => resource1
# resource2
# resource3
# => #<ThreadError: queue empty>
# => "queue empty"
//}

@see Thread::Queue#pop...

Net::HTTPResponse#value -> nil (3037.0)

レスポンスが 2xx(成功)でなかった場合に、対応する 例外を発生させます。

...させます。

@raise HTTPError レスポンスが 1xx であるか、 net/http が知らない
種類のレスポンスである場合に発生します。
@raise HTTPRetriableError レスポンスが 3xx である場合に発生します。
@raise HTTPServerException レスポ...
...合に発生します。
@raise HTTPFatalError レスポンスが 5xx である場合に発生します。

//emlist[例 レスポンスが 2xx(成功)][ruby]{
r
equire 'net/http'

uri = "http://www.example.com/index.html"
r
esponse = Net::HTTP.get_response(URI.parse(uri))
r
esponse.value # => nil
//}...
...//emlist[例 レスポンスが 2xx以外][ruby]{
r
equire 'net/http'

uri = "http://www.example.com/invalid.html"
r
esponse = Net::HTTP.get_response(URI.parse(uri))
begin

r
esponse.value
r
escue => e
e.class # => Net::HTTPServerException
e.message # => 404 "Not Found"
end
//}...

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

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

...Exception#message 属性を error_message にして返します。

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

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

//emlist[例][ruby]{
begin

# ......
...# 何か処理
r
escue => e
r
aise e.exception("an error occurs during hogehoge process") # 詳しいエラーメッセージ
end
//}...

Exception#==(other) -> bool (153.0)

自身と指定された other のクラスが同じであり、 message と backtrace が == メソッドで比較して 等しい場合に true を返します。そうでない場合に false を返します。

...自身と指定された other のクラスが同じであり、
message
と backtrace が == メソッドで比較して
等しい場合に true を返します。そうでない場合に false を返します。

@param other 自身と比較したいオブジェクトを指定します。...
...[例][ruby]{
r
equire "date"
def check_long_month(month)
r
eturn if Date.new(2000, month, -1).day == 31
r
aise "#{month} is not long month"
end

def get_exception
r
eturn begin
yield
r
escue => e
e
end
end

r
esults = [2, 2, 4].map { |e | get_exception { check_long_month(e) } }
p results...
...[RuntimeError, RuntimeError, RuntimeError]
p results.map { |e| e.message }
# => ["2 is not long month", "2 is not long month", "4 is not long month"]

# class, message, backtrace が同一のため true になる
p results[0] == results[1] # => true

# class, backtrace が同一だが、message...
<< 1 2 > >>