るりまサーチ

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

別のキーワード

  1. matrix l
  2. kernel $-l
  3. _builtin $-l
  4. lupdecomposition l
  5. l

ライブラリ

クラス

モジュール

キーワード

検索結果

<< < ... 2 3 4 >>

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...
<< < ... 2 3 4 >>