クラス
-
ARGF
. class (24) - Array (536)
- BasicObject (36)
- Binding (12)
- Complex (72)
- Data (3)
- Dir (92)
-
Encoding
:: Converter (24) - Enumerator (60)
-
Enumerator
:: Lazy (169) - Exception (104)
- Fiber (34)
- File (100)
-
File
:: Stat (12) - Float (21)
- FrozenError (6)
- Hash (56)
- IO (424)
- Integer (162)
- MatchData (106)
- Module (276)
- Mutex (4)
- Numeric (93)
- Object (180)
- Random (36)
- Range (231)
- Rational (85)
- Regexp (12)
- Set (54)
- String (336)
- Struct (36)
- Thread (60)
-
Thread
:: Mutex (20) - ThreadGroup (12)
- TracePoint (105)
- UnboundMethod (12)
モジュール
- Comparable (72)
- Enumerable (108)
キーワード
- & (15)
- * (36)
- ** (13)
- + (15)
- - (15)
-
/ (12) - < (24)
- <= (24)
- == (24)
- === (12)
- =~ (24)
- > (24)
- >= (24)
- [] (174)
- []= (120)
- ^ (3)
- add (12)
- advise (12)
- at (12)
- atime (12)
- backtrace (12)
-
backtrace
_ locations (12) - begin (24)
- between? (12)
- bind (12)
- birthtime (12)
- bsearch (48)
- bytebegin (2)
- byteend (2)
- byteindex (3)
- byteoffset (6)
-
callee
_ id (12) - cause (12)
- ceil (12)
- children (7)
- chr (24)
- chunk (12)
- clamp (12)
-
class
_ variable _ get (12) - clone (12)
-
close
_ write (12) - coerce (12)
- collect (12)
-
collect
_ concat (12) - combination (24)
-
const
_ get (12) -
const
_ missing (12) - convert (12)
- ctime (12)
- cycle (12)
-
define
_ method (24) -
delete
_ at (12) -
deprecate
_ constant (12) - detect (24)
- difference (3)
- digits (24)
- disjoint? (3)
- drop (12)
- dup (12)
- each (108)
-
each
_ byte (24) -
each
_ child (14) -
each
_ line (60) - end (24)
- entries (7)
-
enum
_ for (48) -
eval
_ script (7) - event (12)
- exception (24)
- fcntl (12)
- fdatasync (12)
- feed (12)
- fetch (80)
-
fetch
_ values (22) - fileno (23)
- filter (7)
-
filter
_ map (6) - find (24)
-
find
_ all (12) - finish (12)
- first (48)
-
flat
_ map (12) - flatten (15)
- flatten! (15)
- flock (12)
- floor (12)
- gcd (12)
- gcdlcm (12)
-
initialize
_ copy (12) - insert (12)
- inspect (24)
-
instance
_ eval (24) -
instance
_ method (12) -
instruction
_ sequence (7) - intersection (9)
- isatty (12)
- join (12)
- last (48)
- lcm (12)
- lineno (12)
-
local
_ variable _ get (12) - lstat (12)
- map (12)
- max (70)
- merge (3)
- method (12)
-
method
_ id (12) -
method
_ missing (12) - min (70)
- mtime (12)
- name= (10)
- next (12)
-
next
_ values (12) - offset (24)
- ord (12)
- parameters (7)
- path (20)
- peek (12)
-
peek
_ values (12) - permutation (24)
- pid (12)
- pop (12)
- pos (24)
- pow (24)
- pread (8)
- print (12)
- private (48)
-
private
_ constant (12) -
proper
_ subset? (3) -
proper
_ superset? (3) - public (12)
-
public
_ constant (12) -
public
_ instance _ method (12) -
public
_ method (12) -
public
_ send (24) - putc (12)
- pwrite (8)
- quo (12)
-
raised
_ exception (12) - rand (36)
- rationalize (24)
- read (12)
- readbyte (24)
- readchar (12)
- readlines (36)
- receiver (6)
- reject (12)
-
remove
_ class _ variable (12) -
remove
_ const (12) -
remove
_ instance _ variable (12) -
remove
_ method (12) - reopen (24)
-
repeated
_ combination (24) -
repeated
_ permutation (24) - replace (15)
-
report
_ on _ exception (9) -
report
_ on _ exception= (9) -
respond
_ to? (12) - resume (12)
-
return
_ value (12) -
reverse
_ each (4) - rotate (12)
- rotate! (12)
- round (33)
- run (12)
- sample (24)
- select (12)
-
set
_ backtrace (12) - setbyte (12)
- shift (24)
-
singleton
_ class (12) -
singleton
_ method (12) - size (13)
- sleep (12)
- slice (72)
- stat (12)
- step (93)
- subset? (3)
- subtract (3)
- superset? (3)
- synchronize (12)
- syswrite (12)
- take (12)
- tell (24)
-
to
_ a (7) -
to
_ enum (48) -
to
_ f (12) -
to
_ i (36) -
to
_ path (8) -
to
_ r (12) -
to
_ s (12) - transfer (4)
- truncate (24)
- tty? (12)
-
undef
_ method (12) -
unicode
_ normalize (11) -
unicode
_ normalize! (11) -
unicode
_ normalized? (11) - union (3)
-
values
_ at (12) - wakeup (12)
- with (3)
- write (12)
- zip (24)
- | (15)
検索結果
先頭5件
-
Fiber
# raise -> object (18230.0) -
selfが表すファイバーが最後に Fiber.yield を呼んだ場所で例外を発生させます。
...さない場合、RuntimeError が発生します。
message 引数を渡した場合、message 引数をメッセージとした RuntimeError
が発生します。
その他のケースでは、最初の引数は Exception か Exception
のインスタンスを返す exception メソッドを持......す。
@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(exception , message = nil , backtrace = nil) -> object (18230.0) -
selfが表すファイバーが最後に Fiber.yield を呼んだ場所で例外を発生させます。
...さない場合、RuntimeError が発生します。
message 引数を渡した場合、message 引数をメッセージとした RuntimeError
が発生します。
その他のケースでは、最初の引数は Exception か Exception
のインスタンスを返す exception メソッドを持......す。
@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 (18230.0) -
selfが表すファイバーが最後に Fiber.yield を呼んだ場所で例外を発生させます。
...さない場合、RuntimeError が発生します。
message 引数を渡した場合、message 引数をメッセージとした RuntimeError
が発生します。
その他のケースでは、最初の引数は Exception か Exception
のインスタンスを返す exception メソッドを持......す。
@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
//}... -
TracePoint
# raised _ exception -> Exception (12327.0) -
発生した例外を返します。
...ます。
@raise RuntimeError :raise イベントのためのイベントフックの外側で実行し
た場合に発生します。
//emlist[例][ruby]{
trace = TracePoint.new(:raise) do |tp|
tp.raised_exception # => #<ZeroDivisionError: divided by 0>
end
trace.enable
begi... -
TracePoint
# instruction _ sequence -> RubyVM :: InstructionSequence (9315.0) -
script_compiledイベント発生時にコンパイルされた RubyVM::InstructionSequenceインスタンスを返します。
...pt_compiledイベント発生時にコンパイルされた
RubyVM::InstructionSequenceインスタンスを返します。
//emlist[例][ruby]{
TracePoint.new(:script_compiled) do |tp|
p tp.instruction_sequence # => <RubyVM::InstructionSequence:block in <main>@(eval):1>
end.enable do
eval("put......s 'hello'")
end
//}
@raise RuntimeError :script_compiled イベントのための
イベントフックの外側で実行した場合に発生します。... -
Exception
# exception(error _ message) -> Exception (9221.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
//}... -
Exception
# backtrace _ locations -> [Thread :: Backtrace :: Location] (9215.0) -
バックトレース情報を返します。Exception#backtraceに似ていますが、 Thread::Backtrace::Location の配列を返す点が異なります。
...ption#backtraceに似ていますが、
Thread::Backtrace::Location の配列を返す点が異なります。
現状では Exception#set_backtrace によって戻り値が変化する事はあり
ません。
//emlist[例: test.rb][ruby]{
require "date"
def check_long_month(month)
return if Dat......month, -1).day == 31
raise "#{month} is not long month"
end
def get_exception
return begin
yield
rescue => e
e
end
end
e = get_exception { check_long_month(2) }
p e.backtrace_locations
# => ["test.rb:4:in `check_long_month'", "test.rb:15:in `block in <main>'", "test.rb:9:in `get_ex......ception'", "test.rb:15:in `<main>'"]
//}
@see Exception#backtrace... -
Exception
# exception -> self (9121.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
//}... -
MatchData
# byteoffset(name) -> [Integer , Integer] | [nil , nil] (6316.0) -
name という名前付きグループに対応する部分文字列のバイト単位のオフセットの 配列 [start, end] を返します。
...列のバイト単位のオフセットの
配列 [start, end] を返します。
nameの名前付きグループにマッチした部分文字列がなければ
[nil, nil] を返します。
@param name 名前(シンボルか文字列)
@raise IndexError 正規表現中で定義されていない......ます。
//emlist[例][ruby]{
/(?<year>\d{4})年(?<month>\d{1,2})月(?:(?<day>\d{1,2})日)?/ =~ "2021年1月"
p $~.byteoffset('year') # => [0, 4]
p $~.byteoffset(:year) # => [0, 4]
p $~.byteoffset('month') # => [7, 8]
p $~.byteoffset(:month) # => [7, 8]
p $~.byteoffset('day') # =>......[nil, nil]
p $~.byteoffset('century') # => `offset': undefined group name reference: century (IndexError)
//}
@see MatchData#offset... -
String
# byteindex(pattern , offset = 0) -> Integer | nil (6315.0) -
文字列の offset から右に向かって pattern を検索し、 最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。 見つからなければ nil を返します。
...文字列の offset から右に向かって pattern を検索し、
最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。
見つからなければ nil を返します。
引数 pattern は探索する部分文字列または正規表現で指定......します。
offset が負の場合、文字列の末尾から数えた位置から探索します。
@param pattern 探索する部分文字列または正規表現
@param offset 探索を開始するバイト単位のオフセット
@raise IndexError オフセットが文字列の境界......emlist[例][ruby]{
'foo'.byteindex('f') # => 0
'foo'.byteindex('o') # => 1
'foo'.byteindex('oo') # => 1
'foo'.byteindex('ooo') # => nil
'foo'.byteindex(/f/) # => 0
'foo'.byteindex(/o/) # => 1
'foo'.byteindex(/oo/) # => 1
'foo'.byteindex(/ooo/) # => nil
'foo'.byteindex('o', 1) # => 1
'foo'.byteinde... -
MatchData
# byteoffset(n) -> [Integer , Integer] | [nil , nil] (6311.0) -
n 番目の部分文字列のバイト単位のオフセットの 配列 [start, end] を返します。
...のオフセットの
配列 [start, end] を返します。
n番目の部分文字列がマッチしていなければ [nil, nil] を返します。
@param n 部分文字列を指定する数値
@raise IndexError 範囲外の n を指定した場合に発生します。
@see MatchData#offset... -
MatchData
# bytebegin(n) -> Integer | nil (6245.0) -
n 番目の部分文字列先頭のバイトオフセットを返します。
...ル。
@raise IndexError 範囲外の n を指定した場合に発生します。
@raise IndexError 正規表現中で定義されていない name を指定した場合に発生します。
//emlist[例][ruby]{
/(c).*(いう).*(e.*)/ =~ 'abcあいうdef'
p $~ # => #<MatchData "cあ......$~.bytebegin(0) # => 2
p $~.bytebegin(1) # => 2
p $~.bytebegin(2) # => 6
p $~.bytebegin(3) # => 13
p $~.bytebegin(4) # => index 4 out of matches (IndexError)
//}
//emlist[シンボルを指定する例][ruby]{
/(?<key>\S+):\s*(?<value>\S+)/ =~ "name: ruby"
$~ # => #<MatchData "na......me: ruby" key:"name" value:"ruby">
$~.bytebegin(:key) # => 0
$~.bytebegin(:value) # => 6
$~.bytebegin(:foo) # => undefined group name reference: foo (IndexError)
//}... -
MatchData
# bytebegin(name) -> Integer | nil (6245.0) -
n 番目の部分文字列先頭のバイトオフセットを返します。
...ル。
@raise IndexError 範囲外の n を指定した場合に発生します。
@raise IndexError 正規表現中で定義されていない name を指定した場合に発生します。
//emlist[例][ruby]{
/(c).*(いう).*(e.*)/ =~ 'abcあいうdef'
p $~ # => #<MatchData "cあ......$~.bytebegin(0) # => 2
p $~.bytebegin(1) # => 2
p $~.bytebegin(2) # => 6
p $~.bytebegin(3) # => 13
p $~.bytebegin(4) # => index 4 out of matches (IndexError)
//}
//emlist[シンボルを指定する例][ruby]{
/(?<key>\S+):\s*(?<value>\S+)/ =~ "name: ruby"
$~ # => #<MatchData "na......me: ruby" key:"name" value:"ruby">
$~.bytebegin(:key) # => 0
$~.bytebegin(:value) # => 6
$~.bytebegin(:foo) # => undefined group name reference: foo (IndexError)
//}... -
MatchData
# byteend(n) -> Integer | nil (6245.0) -
n 番目の部分文字列終端のバイトオフセットを返します。
...ル。
@raise IndexError 範囲外の n を指定した場合に発生します。
@raise IndexError 正規表現中で定義されていない name を指定した場合に発生します。
//emlist[例][ruby]{
/(c).*(いう).*(e.*)/ =~ 'abcあいうdef'
p $~ # => #<MatchData "cあい......~.byteend(0) # => 15
p $~.byteend(1) # => 3
p $~.byteend(2) # => 12
p $~.byteend(3) # => 15
p $~.byteend(4) # => index 4 out of matches (IndexError)
//}
//emlist[シンボルを指定する例][ruby]{
/(?<key>\S+):\s*(?<value>\S+)/ =~ "name: ruby"
$~ # => #<MatchData "name: ruby" ke......y:"name" value:"ruby">
$~.byteend(:key) # => 4
$~.byteend(:value) # => 10
$~.byteend(:foo) # => undefined group name reference: foo (IndexError)
//}... -
MatchData
# byteend(name) -> Integer | nil (6245.0) -
n 番目の部分文字列終端のバイトオフセットを返します。
...ル。
@raise IndexError 範囲外の n を指定した場合に発生します。
@raise IndexError 正規表現中で定義されていない name を指定した場合に発生します。
//emlist[例][ruby]{
/(c).*(いう).*(e.*)/ =~ 'abcあいうdef'
p $~ # => #<MatchData "cあい......~.byteend(0) # => 15
p $~.byteend(1) # => 3
p $~.byteend(2) # => 12
p $~.byteend(3) # => 15
p $~.byteend(4) # => index 4 out of matches (IndexError)
//}
//emlist[シンボルを指定する例][ruby]{
/(?<key>\S+):\s*(?<value>\S+)/ =~ "name: ruby"
$~ # => #<MatchData "name: ruby" ke......y:"name" value:"ruby">
$~.byteend(:key) # => 4
$~.byteend(:value) # => 10
$~.byteend(:foo) # => undefined group name reference: foo (IndexError)
//}... -
Enumerator
# next -> object (6227.0) -
「次」のオブジェクトを返します。
...ます。
列挙が既に最後へ到達している場合は、
StopIteration 例外を発生します。このとき列挙状態は変化しません。
つまりもう一度 next を呼ぶと再び例外が発生します。
next メソッドによる外部列挙の状態は他のイテレータ......@raise StopIteration 列挙状態が既に最後へ到達しているとき
@see Enumerator#rewind
//emlist[例1][ruby]{
str = "xyz"
enum = str.each_byte
str.bytesize.times do
puts enum.next
end
# => 120
# 121
# 122
//}
//emlist[例2][ruby]{
str = "xyz"
enum = str.each_byte......uts enum.next while true
rescue StopIteration
puts "iteration reached at end"
end
# => 120
# 121
# 122
# iteration reached at end
puts enum.next
#=> 再度 StopIteration 例外が発生
//}
//emlist[例3: Kernel.#loop は StopIteration を捕捉します。][ruby]{
st... -
IO
# write(*str) -> Integer (6227.0) -
IOポートに対して str を出力します。str が文字列でなけ れば to_s による文字列化を試みます。 実際に出力できたバイト数を返します。
...IOポートに対して str を出力します。str が文字列でなけ
れば to_s による文字列化を試みます。
実際に出力できたバイト数を返します。
IO#syswrite を除く全ての出力メソッドは、最終的に
"write" という名のメソッドを呼び出......str 自身に書き込みたい文字列を指定します。
@raise IOError 自身が書き込み用にオープンされていなければ発生します。
@raise Errno::EXXX 出力に失敗した場合に発生します。
//emlist[例][ruby]{
File.open("textfile", "w+") do |f|
f.write("Th......is is") # => 7
end
File.read("textfile") # => "This is"
//}
//emlist[複数引数の例][ruby]{
File.open("textfile", "w+") do |f|
f.write("This is", " a test\n") # => 15
end
File.read("textfile") # => "This is a test\n"
//}...