Linux server1.dn-server.com 4.18.0-553.89.1.lve.el8.x86_64 #1 SMP Wed Dec 10 13:58:50 UTC 2025 x86_64
LiteSpeed
Server IP : 195.201.204.189 & Your IP : 216.73.217.130
Domains :
Cant Read [ /etc/named.conf ]
User : beriska1
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
opt /
alt /
ruby19 /
share /
ri /
1.9.1 /
system /
Observable /
Delete
Unzip
Name
Size
Permission
Date
Action
add_observer-i.ri
855
B
-rw-r--r--
2023-07-26 17:26
cdesc-Observable.ri
4.07
KB
-rw-r--r--
2023-07-26 17:26
changed%3f-i.ri
289
B
-rw-r--r--
2023-07-26 17:26
changed-i.ri
505
B
-rw-r--r--
2023-07-26 17:26
count_observers-i.ri
265
B
-rw-r--r--
2023-07-26 17:26
delete_observer-i.ri
488
B
-rw-r--r--
2023-07-26 17:26
delete_observers-i.ri
257
B
-rw-r--r--
2023-07-26 17:26
notify_observers-i.ri
621
B
-rw-r--r--
2023-07-26 17:26
Save
Rename
U:RDoc::NormalModule[iI"Observable:EF@0o:RDoc::Markup::Document:@parts[o;;[o:RDoc::Markup::Paragraph;[I"MThe Observer pattern (also known as publish/subscribe) provides a simple;TI"Omechanism for one object to inform a set of interested third-party objects;TI"when its state changes.;To:RDoc::Markup::BlankLine S:RDoc::Markup::Heading: leveli: textI"Mechanism;T@o; ;[I"2The notifying class mixes in the +Observable+;TI"Lmodule, which provides the methods for managing the associated observer;TI" objects.;T@o; ;[I"EThe observers must implement a method called +update+ to receive;TI"notifications.;T@o; ;[I" The observable object must:;To:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0;[o; ;[I""assert that it has +#changed+;To;;0;[o; ;[I"call +#notify_observers+;T@S;;i; I"Example;T@o; ;[ I"KThe following example demonstrates this nicely. A +Ticker+, when run,;TI"Qcontinually receives the stock +Price+ for its <tt>@symbol</tt>. A +Warner+;TI"Lis a general observer of the price, and two warners are demonstrated, a;TI"O+WarnLow+ and a +WarnHigh+, which print a warning if the price is below or;TI"*above their set limits, respectively.;T@o; ;[I"MThe +update+ callback allows the warners to run without being explicitly;TI"Scalled. The system is set up with the +Ticker+ and several observers, and the;TI"Lobservers do their duty without the top-level code having to interfere.;T@o; ;[ I"LNote that the contract between publisher and subscriber (observable and;TI"Pobserver) is not declared or enforced. The +Ticker+ publishes a time and a;TI"Lprice, and the warners receive that. But if you don't ensure that your;TI"6contracts are correct, nothing else can warn you.;T@o:RDoc::Markup::Verbatim;[>I"require "observer" ;FI" ;FI"Aclass Ticker ### Periodically fetch a stock price. ;FI" include Observable ;FI" ;FI" def initialize(symbol) ;FI" @symbol = symbol ;FI" end ;FI" ;FI" def run ;FI" lastPrice = nil ;FI" loop do ;FI"( price = Price.fetch(@symbol) ;FI"- print "Current price: #{price}\n" ;FI"! if price != lastPrice ;FI"8 changed # notify observers ;FI" lastPrice = price ;FI"/ notify_observers(Time.now, price) ;FI" end ;FI" sleep 1 ;FI" end ;FI" end ;FI" end ;FI" ;FI"Oclass Price ### A mock class to fetch a stock price (60 - 140). ;FI" def Price.fetch(symbol) ;FI" 60 + rand(80) ;FI" end ;FI" end ;FI" ;FI"Gclass Warner ### An abstract observer of Ticker objects. ;FI"% def initialize(ticker, limit) ;FI" @limit = limit ;FI"# ticker.add_observer(self) ;FI" end ;FI" end ;FI" ;FI"class WarnLow < Warner ;FI"= def update(time, price) # callback for observer ;FI" if price < @limit ;FI"E print "--- #{time.to_s}: Price below #@limit: #{price}\n" ;FI" end ;FI" end ;FI" end ;FI" ;FI"class WarnHigh < Warner ;FI"= def update(time, price) # callback for observer ;FI" if price > @limit ;FI"E print "+++ #{time.to_s}: Price above #@limit: #{price}\n" ;FI" end ;FI" end ;FI" end ;FI" ;FI"!ticker = Ticker.new("MSFT") ;FI"WarnLow.new(ticker, 80) ;FI"WarnHigh.new(ticker, 120) ;FI"ticker.run ;Fo; ;[I"Produces:;T@o;;[I"Current price: 83 ;FI"Current price: 75 ;FI":--- Sun Jun 09 00:10:25 CDT 2002: Price below 80: 75 ;FI"Current price: 90 ;FI"Current price: 134 ;FI"<+++ Sun Jun 09 00:10:25 CDT 2002: Price above 120: 134 ;FI"Current price: 134 ;FI"Current price: 112 ;FI"Current price: 79 ;FI"9--- Sun Jun 09 00:10:25 CDT 2002: Price below 80: 79;F: @fileI"lib/observer.rb;T;0[ [ [ [[I" class;F[[:public[ [:protected[ [:private[ [I" instance;F[[;[[I"add_observer;F@�[I"changed;F@�[I" changed?;F@�[I"count_observers;F@�[I"delete_observer;F@�[I"delete_observers;F@�[I"notify_observers;F@�[;[ [;[