るりまサーチ

最速Rubyリファレンスマニュアル検索!
36件ヒット [1-36件を表示] (0.142秒)
トップページ > クエリ:t[x] > クエリ:Ruby[x] > クエリ:ruby[x] > クエリ:initialize[x] > 種類:クラス[x]

別のキーワード

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

ライブラリ

キーワード

検索結果

Thread::Backtrace::Location (6081.0)

Ruby のフレームを表すクラスです。

...Ruby のフレームを表すクラスです。

Kernel.#caller_locations から生成されます。

//emlist[例1][ruby]{
# caller_locations.rb
def a(skip)
caller_locations(skip)
end
def b(skip)
a(skip)
end
def c(skip)
b(skip)
end

c(0..2).map do |call|
puts call.to_s
end
//}

例1の実...
...caller_locations.rb:2:in `a'
caller_locations.rb:5:in `b'
caller_locations.rb:8:in `c'

//emlist[例2][ruby]{
# foo.rb
class
Foo
attr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)
end
end

Foo.new(0..2).locations.map do |call|
puts call.to_s
end
//}...
...例2の実行結果:

init.rb:4:in `initialize'
init.rb:8:in `new'
init.rb:8:in `<main>'

=== 参考

* Ruby VM アドベントカレンダー #4 vm_backtrace.c: https://www.atdot.net/~ko1/diary/201212.html#d4...

Thread::ConditionVariable (6055.0)

スレッドの同期機構の一つである状態変数を実現するクラスです。

...の一つである状態変数を実現するクラスです。

以下も ConditionVariable を理解するのに参考になります。

https://ruby-doc.com/docs/ProgrammingRuby/html/tut_threads.html#UF

=== Condition Variable とは

あるスレッド A が排他領域で動いていたとし...
...場合に Condition Variable を使って wait しています。

require 'thread'

class
TinyQueue
def initialize(max=2)
@max = max
@full = ConditionVariable.new
@empty = ConditionVariable.new
@mutex = Mutex.new
@q = []
end

def count
@q.size...
...print "sent ", obj, "\n"
end
q.send nil
}

l.push th

t
h = Thread.new {
while obj = q.recv
print "recv ", obj, "\n"
end
}
l.push th

l.each do |t|
t
.join
end
end

実行すると以下のように出力します。

$ ruby condv...

BasicObject (6051.0)

特殊な用途のために意図的にほとんど何も定義されていないクラスです。 Objectクラスの親にあたります。Ruby 1.9 以降で導入されました。

...義されていないクラスです。
Objectクラスの親にあたります。Ruby 1.9 以降で導入されました。

=== 性質
BasicObject クラスは Object クラスからほとんどのメソッドを取り除いたクラスです。

Object クラスは様々な便利なメソッド...
...bject ではなく BasicObject から派生
して問題を解決できます。

=== 注意
通常のクラスは Object またはその他の適切なクラスから派生すべきです。
真に必要な場合にだけ BasicObject から派生してください。

=== 例

//emlist[例][ruby]{...
...class Proxy < BasicObject
def initialize(target)
@target = target
end

def method_missing(message, *args)
@target.__send__(message, *args)
end
end

proxy = Proxy.new("1")
proxy.to_i #=> 1
//}...