353件ヒット
[301-353件を表示]
(0.142秒)
クラス
- Enumerator (44)
-
Enumerator
:: Lazy (44) -
Enumerator
:: Yielder (27) - Exception (22)
- Fiber (27)
- Object (21)
- Pathname (22)
- Proc (22)
- StopIteration (11)
- Thread (22)
モジュール
- Enumerable (91)
キーワード
- << (11)
- == (11)
- [] (11)
- alive? (11)
-
backtrace
_ locations (11) - call (11)
- compact (3)
- each (11)
-
each
_ entry (33) -
enum
_ for (22) - feed (11)
- find (11)
-
max
_ by (44) -
next
_ values (11) -
peek
_ values (11) - raise (5)
- result (11)
- resume (11)
-
sort
_ by (22) - tap (7)
-
thread
_ variable _ get (11) -
to
_ enum (22) -
to
_ proc (5) -
yield
_ self (14)
検索結果
先頭5件
-
Pathname
# each _ entry {|pathname| . . . } -> nil (117.0) -
Dir.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。
...Dir.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。
//emlist[例][ruby]{
require "pathname"
Pathname("/usr/local").each_entry {|f| p f }
# => #<Pathname:.>
# => #<Pathname:..>
# => #<Pathname:bin>
# => #<Pathname:etc>
# => #<Pathname:include>
# => #<Pathname:lib>
# => #<Pathna... -
Fiber
# resume(*arg = nil) -> object (113.0) -
自身が表すファイバーへコンテキストを切り替えます。 自身は resume を呼んだファイバーの子となります。
...出した後に resume を呼び出す事はでき
ません。
@param arg self が表すファイバーに渡したいオブジェクトを指定します。
@return コンテキストの切り替えの際に Fiber.yield に与えられた引数
を返します。ブロックの終了ま......また、Fiber#transfer を呼び出した後に resume を
呼び出した場合に発生します。
//emlist[例:][ruby]{
f = Fiber.new do
Fiber.yield(:hoge)
:fuga
end
p f.resume() #=> :hoge
p f.resume() #=> :fuga
p f.resume() #=> FiberError: dead fiber called
//}... -
Thread
# [](name) -> object | nil (113.0) -
name に対応したスレッドに固有のデータを取り出します。 name に対応するスレッド固有データがなければ nil を返し ます。
...取り出します。
name に対応するスレッド固有データがなければ nil を返し
ます。
@param name スレッド固有データのキーを文字列か Symbol で指定します。
//emlist[例][ruby]{
[
Thread.new { Thread.current["name"] = "A" },
Thread.new { Thread.curr......と異なる変数を返す事に注意してください。
//emlist[][ruby]{
def meth(newvalue)
begin
oldvalue = Thread.current[:name]
Thread.current[:name] = newvalue
yield
ensure
Thread.current[:name] = oldvalue
end
end
//}
この関数に与えるブロックがFiberを......コープとしては
正しく動作しません。
//emlist[][ruby]{
f = Fiber.new {
meth(1) {
Fiber.yield
}
}
meth(2) {
f.resume
}
f.resume
p Thread.current[:name]
# => nil if fiber-local
# => 2 if thread-local (The value 2 is leaked to outside of meth method.)
//}
Fiber を切り替... -
Exception
# ==(other) -> bool (107.0) -
自身と指定された other のクラスが同じであり、 message と backtrace が == メソッドで比較して 等しい場合に true を返します。そうでない場合に false を返します。
...い場合に false を返します。
@param other 自身と比較したいオブジェクトを指定します。
自身と異なるクラスのオブジェクトを指定した場合は
Exception#exception を実行して変換を試みます。
//emlist[例][ruby]{
req......"
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_exception { check_long_month(e) } }
p results.map { |e| e.class }
# =>......esults.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 になる
p results... -
Object
# tap {|x| . . . } -> self (107.0) -
self を引数としてブロックを評価し、self を返します。
...self を引数としてブロックを評価し、self を返します。
メソッドチェインの途中で直ちに操作結果を表示するために
メソッドチェインに "入り込む" ことが、このメソッドの主目的です。
//emlist[][ruby]{
(1..10) .ta......p {|x| puts "original: #{x}" }
.to_a .tap {|x| puts "array: #{x}" }
.select {|x| x.even? } .tap {|x| puts "evens: #{x}" }
.map {|x| x*x } .tap {|x| puts "squares: #{x}" }
//}
@see Object#yield_self... -
Pathname
# find {|pathname| . . . } -> nil (107.0) -
self 配下のすべてのファイルやディレクトリを 一つずつ引数 pathname に渡してブロックを実行します。
...self 配下のすべてのファイルやディレクトリを
一つずつ引数 pathname に渡してブロックを実行します。
require 'find'
Find.find(self.to_s) {|f| yield Pathname.new(f)}
と同じです。
ブロックを省略した場合は Enumerator を返します。
@see... -
Pathname
# find(ignore _ error: true) {|pathname| . . . } -> nil (107.0) -
self 配下のすべてのファイルやディレクトリを 一つずつ引数 pathname に渡してブロックを実行します。
...self 配下のすべてのファイルやディレクトリを
一つずつ引数 pathname に渡してブロックを実行します。
require 'find'
Find.find(self.to_s) {|f| yield Pathname.new(f)}
と同じです。
ブロックを省略した場合は Enumerator を返します。
@para...