るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

検索結果

Observable (38042.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)...
...if price < @limit
print "--- #{time.to_s}: Price below #@limit: #{price}\n"
end
end
end

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