るりまサーチ

最速Rubyリファレンスマニュアル検索!
12件ヒット [1-12件を表示] (0.008秒)
トップページ > クエリ:<[x] > クエリ:Observable[x]

別のキーワード

  1. _builtin <
  2. bigdecimal <
  3. comparable <
  4. integer <
  5. module <

ライブラリ

検索結果

Observable (38048.0)

Observer パターンを提供するモジュールです。

...ジュールです。

Mix-in により Observer パターンを提供します。

Observable
モジュールを include したクラスは
Observable
#changed メソッドにより更新フラグを立て、
Observable
#notify_observers が呼び出されると
更新フラグが立っている場...
...ッドを呼び出す)。
Observable
#notify_observers の引数は
そのままオブザーバの update メソッドに渡されます。

=== サンプルコード
require "observer"

class Ticker ### Periodically fetch a stock price.
include Observable

def initialize(symbol)...
....add_observer(self)
end
end

class WarnLow < Warner
def update(time, price) # callback for observer
if price < @limit
print "--- #{time.to_s}: Price below #@limit: #{price}\n"
end
end
end

class WarnHigh < Warner
def update(time, price) # callb...