別のキーワード
クラス
-
REXML
:: ParseException (22) - TracePoint (11)
モジュール
- Timeout (19)
キーワード
- CSV (11)
-
NEWS for Ruby 2
. 4 . 0 (8) -
NEWS for Ruby 2
. 6 . 0 (6) -
NEWS for Ruby 3
. 0 . 0 (4) - ParseException (11)
- context (11)
- logger (11)
- new (11)
-
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 3 feature (11) -
ruby 1
. 9 feature (11) - timeout (19)
- 制御構造 (11)
検索結果
先頭5件
-
REXML
:: ParseException # line -> Integer (21101.0) -
パースエラーが起きた(XML上の)場所を行数で返します。
パースエラーが起きた(XML上の)場所を行数で返します。 -
REXML
:: ParseException (6006.0) -
XML のパースに失敗したときに生じる例外です。
...XML のパースに失敗したときに生じる例外です。
//emlist[][ruby]{
require 'rexml/document'
begin
REXML::Document.new("<a>foo\n</b></a> ")
rescue REXML::ParseException => ex
ex.position # => 16
ex.line # => 2
ex.context # => [16, 2, 2]
end
//}... -
REXML
:: ParseException # context -> [Integer , Integer , Integer] (3024.0) -
パースエラーが起きた(XML上の)場所を返します。
...を返します。
要素3個の配列で、
[position, lineno, line]
という形で返します。
position, line は
REXML::ParseException#position
REXML::ParseException#line
と同じ値です。
lineno は IO#lineno が返す意味での行数です。
通常は line と同じ値です。... -
Timeout
. # timeout(sec , exception _ class = nil) {|i| . . . } -> object (132.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
...sec 秒の期限付きで実行します。
ブロックの実行時間が制限を過ぎたときは例外
Timeout::Error が発生します。
exception_class を指定した場合には Timeout::Error の代わりに
その例外が発生します。
ブロックパラメータ i は sec がは......のときは制限時間なしで
ブロックを実行します。
@param sec タイムアウトする時間を秒数で指定します.
@param exception_class タイムアウトした時、発生させる例外を指定します.
@param message エラーメッセージを指定します.省略し......{
# system だととまらない
# system("./loop.sh")
com = IO.popen("./loop.sh")
pid = com.pid
while line = com.gets
print line
end
}
rescue Timeout::Error => err
puts "timeout: shell execution."
Process.kill('SIGINT', pid)
printf "[re... -
Timeout
. # timeout(sec , exception _ class , message) {|i| . . . } -> object (132.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
...sec 秒の期限付きで実行します。
ブロックの実行時間が制限を過ぎたときは例外
Timeout::Error が発生します。
exception_class を指定した場合には Timeout::Error の代わりに
その例外が発生します。
ブロックパラメータ i は sec がは......のときは制限時間なしで
ブロックを実行します。
@param sec タイムアウトする時間を秒数で指定します.
@param exception_class タイムアウトした時、発生させる例外を指定します.
@param message エラーメッセージを指定します.省略し......{
# system だととまらない
# system("./loop.sh")
com = IO.popen("./loop.sh")
pid = com.pid
while line = com.gets
print line
end
}
rescue Timeout::Error => err
puts "timeout: shell execution."
Process.kill('SIGINT', pid)
printf "[re... -
Timeout
. # timeout(sec , exception _ class = nil) {|i| . . . } -> object (131.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
...sec 秒の期限付きで実行します。
ブロックの実行時間が制限を過ぎたときは例外
Timeout::Error が発生します。
exception_class を指定した場合には Timeout::Error の代わりに
その例外が発生します。
ブロックパラメータ i は sec がは......のときは制限時間なしで
ブロックを実行します。
@param sec タイムアウトする時間を秒数で指定します.
@param exception_class タイムアウトした時、発生させる例外を指定します.
例 長い計算のタイムアウト
require 'timeout'
def c......{
# system だととまらない
# system("./loop.sh")
com = IO.popen("./loop.sh")
pid = com.pid
while line = com.gets
print line
end
}
rescue Timeout::Error => err
puts "timeout: shell execution."
Process.kill('SIGINT', pid)
printf "[re... -
NEWS for Ruby 2
. 6 . 0 (84.0) -
NEWS for Ruby 2.6.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...ser| cond(user) }
//}
* 例外が捕捉されず、バックトレースとエラーメッセージが表示されるときに、
例外の Exception#cause も表示されるようになりました。 8257
* フリップフロップが非推奨になりました。 5400
=== 組み込み......ing#source_location 追加 14230
* bindingのソースコード上の位置を __FILE__ と __LINE__ の二要素配列として返します。
従来でも eval("[__FILE__, __LINE__]", binding) とすることでこれらの情報は得られましたが、
将来的に......け取り、環境変数名と値のペアを新しいキーと値に変換できるようになりました。 15143
* Exception
* 新規オプション
* Exception#full_message が :highlight と :order を受け付けるようになりました。 14324
* Hash
* 変更され... -
NEWS for Ruby 3
. 0 . 0 (36.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...st{
def method_missing(meth, ...)
send(:"do_#{meth}", ...)
end
//}
* Pattern matching (`case/in`) is no longer experimental. 17260
* One-line pattern matching is redesigned. [EXPERIMENTAL]
* `=>` is added. It can be used like a rightward assignment.
17260
* `in` i......the toplevel scope is now a RuntimeError.
14541
* Assigning to a numbered parameter is now a SyntaxError instead of
a warning.
== Command line options
=== `--help` option
When the environment variable `RUBY_PAGER` or `PAGER` is present and has
a non-empty value, and the standard input a......y2_keywords` will no longer keep empty keyword splats, those are now removed just as they are for methods not using `ruby2_keywords`.
* When an exception is caught in the default handler, the error message and backtrace are printed in order from the innermost. 8661
* Accessing an uninitialized i... -
logger (36.0)
-
ログを記録するためのライブラリです。
...o do!")
path = "a_non_existent_file"
begin
File.foreach(path) do |line|
unless line =~ /^(\w+) = (.*)$/
logger.error("Line in wrong format: #{line.chomp}")
end
end
rescue => err
logger.fatal("Caught exception; exiting")
logger.fatal(err)
end
//}
上の例ではログにはWA......出力例です。
W, [2017-12-07T02:22:53.649000 #11601] WARN -- : Nothing to do!
F, [2017-12-07T02:22:53.649172 #11601] FATAL -- : Caught exception; exiting
F, [2017-12-07T02:22:53.649222 #11601] FATAL -- : No such file or directory @ rb_sysopen - a_non_existent_file (Errno::ENOENT)
logg... -
制御構造 (36.0)
-
制御構造 条件分岐: * if * unless * case 繰り返し: * while * until * for * break * next * redo * retry 例外処理: * raise * begin その他: * return * BEGIN * END
...の戻り値はその引数になります。
====[a:next] next
//emlist[例][ruby]{
# 空行を捨てるcat
ARGF.each_line do |line|
next if line.strip.empty?
print line
end
//}
文法:
next
next val
nextはもっとも内側のループの次の繰り返しにジャ......る処理が成功するまで処理を繰り返すようなループを作
ることができます。
//emlist[][ruby]{
begin
do_something # exception raised
rescue
# handles error
retry # restart from beginning
end
//}
rescue 節以外で retry が用いられた場合には例外 Syntax......e SyntaxError.new("invalid syntax")
raise # 最後の例外の再発生
//}
文法:
raise
raise messageまたはexception
raise error_type, message
raise error_type, message, traceback
例外を発生させます。第一の形式では直前の... -
NEWS for Ruby 2
. 4 . 0 (30.0) -
NEWS for Ruby 2.4.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...うになりました。
half には :even, :up, :down が指定可能です。 12548 12958 12953
* IO
* IO#gets, IO#readline, IO#each_line, IO#readlines, IO.foreach は
chomp というキーワード引数を受け付けるようになりました。12553
* Kernel
* Kernel......asecmp? を追加 12786
* String#concat, String#prepend 複数の引数を受け付けるようになりました 12333
* String#each_line, String#lines 省略可能なキーワード引数 chomp を受け付けるようになりました 12553
* String#match? を追加 12898
* Strin......ol#swapcase は
全ての Unicode に対して動作するようになりました。10085
* Thread
* Thread#report_on_exception, Thread.report_on_exception を追加 6647
* TracePoint
* TracePoint#callee_id を追加 12747
* Warning
* Warningという名前のモジュー... -
TracePoint
. new(*events) {|obj| . . . } -> TracePoint (30.0) -
新しい TracePoint オブジェクトを作成して返します。トレースを有効 にするには TracePoint#enable を実行してください。
...TracePoint#enable を実行してください。
//emlist[例:irb で実行した場合][ruby]{
trace = TracePoint.new(:call) do |tp|
p [tp.lineno, tp.defined_class, tp.method_id, tp.event]
end
# => #<TracePoint:0x007f17372cdb20>
trace.enable
# => false
puts "Hello, TracePoint!"
# ...
# [69,......[][ruby]{
trace.disable
//}
@param events トレースするイベントを String か Symbol で任
意の数指定します。
: :line
式の評価。
: :class
クラス定義、特異クラス定義、モジュール定義への突入。
: :end
クラス定義、特異......ッドを実行した場合には
RuntimeError が発生します。
//emlist[例][ruby]{
TracePoint.trace(:line) do |tp|
p tp.raised_exception
end
# => RuntimeError: 'raised_exception' not supported by this event
//}
イベントフックの外側で、発生したイベントに関連する...