Misc #10791 ยป update_doc_for_observable.patch
| lib/observer.rb | ||
|---|---|---|
|
# def run
|
||
|
# last_price = nil
|
||
|
# loop do
|
||
|
# price = Price.fetch(@symbol)
|
||
|
# price = Price.fetch
|
||
|
# print "Current price: #{price}\n"
|
||
|
# if price != last_price
|
||
|
# changed # notify observers
|
||
| ... | ... | |
|
# end
|
||
|
#
|
||
|
# class Price ### A mock class to fetch a stock price (60 - 140).
|
||
|
# def self.fetch(symbol)
|
||
|
# def self.fetch
|
||
|
# 60 + rand(80)
|
||
|
# end
|
||
|
# end
|
||
|
-
|
||