るりまサーチ

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

別のキーワード

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

ライブラリ

キーワード

検索結果

<< 1 2 3 > >>

Exception#message -> String (18120.0)

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

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

//emlist[例][ruby]{
begin
1 + nil
rescue => e
p e.message #=> "nil can't be coerced into Fixnum"
end

//}...

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

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

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

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

//emlist[例][ruby]{
begin
raise "test"
rescue => 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 (R...
...untimeError)\n"
$stderr = STDERR
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"
end

//}

@see Exception.to_tty?...

Exception#to_s -> String (3020.0)

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

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

//emlist[例][ruby]{
begin
1 + nil
rescue => e
p e.message #=> "nil can't be coerced into Fixnum"
end

//}...

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

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

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

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

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

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

//}...

Fiber#raise(exception, message = nil, backtrace = nil) -> object (145.0)

selfが表すファイバーが最後に Fiber.yield を呼んだ場所で例外を発生させます。

...に終了している場合、
FiberError が発生します。

引数を渡さない場合、RuntimeError が発生します。
message
引数を渡した場合、message 引数をメッセージとした RuntimeError
が発生します。

その他のケースでは、最初の引数は Exceptio...
...を指定できます。

@param message 例外のメッセージとなる文字列です。
@param exception 発生させる例外です。
@param backtrace 例外発生時のスタックトレースです。文字列の配列で指定します。

//emlist[例][ruby]{
f = Fiber.new { Fiber.yield }...
...f.resume
f.raise "Error!" # => Error! (RuntimeError)
//}

//emlist[ファイバー内のイテレーションを終了させる例][ruby]{
f = Fiber.new do
loop do
Fiber.yield(:loop)
end

:exit
end


p f.resume # => :loop
p f.raise StopIteration # => :exit
//}...

絞り込み条件を変える

Fiber#raise(message) -> object (145.0)

selfが表すファイバーが最後に Fiber.yield を呼んだ場所で例外を発生させます。

...に終了している場合、
FiberError が発生します。

引数を渡さない場合、RuntimeError が発生します。
message
引数を渡した場合、message 引数をメッセージとした RuntimeError
が発生します。

その他のケースでは、最初の引数は Exceptio...
...を指定できます。

@param message 例外のメッセージとなる文字列です。
@param exception 発生させる例外です。
@param backtrace 例外発生時のスタックトレースです。文字列の配列で指定します。

//emlist[例][ruby]{
f = Fiber.new { Fiber.yield }...
...f.resume
f.raise "Error!" # => Error! (RuntimeError)
//}

//emlist[ファイバー内のイテレーションを終了させる例][ruby]{
f = Fiber.new do
loop do
Fiber.yield(:loop)
end

:exit
end


p f.resume # => :loop
p f.raise StopIteration # => :exit
//}...

WIN32OLE_TYPE#default_event_sources -> [WIN32OLE_TYPE] (97.0)

型が持つソースインターフェイスを取得します。

...び出し(=イベント通知)をトレースして調べるプ
ログラムです。イベントを受け付けるために、
WIN32OLE_EVENT.message_loopの呼び出しが必要な点に注意してください。
ここでは最終イベントのStatusTextChangeイベントのメッセージ...
...nitialize
@completed = false
end

attr_reader :completed
end

source.ole_methods.each do |m|
WebEvent.module_eval do
define_method("on#{m.name}") do |*arg|
if arg[0] == "ページが表示されました"
@completed = true
end

puts "#{Time.now}: #{m.n...
...ame} was called"
p arg
end
end

end

evt = WIN32OLE_EVENT.new(ctl)
evt.handler = WebEvent.new
ctl.navigate2 'http://www.ruby-lang.org/'
loop do
break if evt.handler.completed
WIN32OLE_EVENT.message_loop
end

ctl.Quit

このプログラムを実行するとWindows7のIE8環...

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

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

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

@param other 自身と比較したいオブジェクトを指定します。...
...て変換を試みます。

//emlist[例][ruby]{
require "date"
def check_long_month(month)
return if Date.new(2000, month, -1).day == 31
raise "#{month} is not long month"
end


def get_exception
return begin
yield
rescue => e
e
end

end


results = [2, 2, 4].map { |e | get_exceptio...
...ntimeError]
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 がことなるため false に...

Exception#exception -> self (52.0)

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

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

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

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

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

//}...

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

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

...mlist[例][ruby]{
require '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]{
require...
...Queue.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.join
q.pop(true)
rescue => e
p e
p e.message
end


# => resource1
# resource2
# resource3
# => #<ThreadError: queue empty>
# =>...

絞り込み条件を変える

<< 1 2 3 > >>