12件ヒット
[1-12件を表示]
(0.033秒)
ライブラリ
- observer (12)
検索結果
先頭1件
-
Observable (31.0)
-
Observer パターンを提供するモジュールです。
...### Periodically fetch a stock price.
include Observable
def initialize(symbol)
@symbol = symbol
end
def run
last_price = nil
loop do
price = Price.fetch(@symbol)
print "Current price: #{price}\n"
if price != last_price
cha......end
sleep 1
end
end
end
class Price ### A mock class to fetch a stock price (60 - 140).
def self.fetch(symbol)
60 + rand(80)
end
end
class Warner ### An abstract observer of Ticker objects.
def initialize(ticker, limit)
@l...