Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 33 lines (28 sloc) 0.47 kB
99d0354 Initial revision
matz authored
1 #! /usr/local/bin/ruby
2
3 require "thread"
4 require "observer"
5
6 class Tick
7 include Observable
8 def initialize
9 Thread.start do
a2af08d This commit was generated by cvs2svn to compensate for changes in r372,
matz authored
10 loop do
99d0354 Initial revision
matz authored
11 sleep 0.999
a2af08d This commit was generated by cvs2svn to compensate for changes in r372,
matz authored
12 now = Time.now
99d0354 Initial revision
matz authored
13 changed
a2af08d This commit was generated by cvs2svn to compensate for changes in r372,
matz authored
14 notify_observers(now.hour, now.min, now.sec)
99d0354 Initial revision
matz authored
15 end
16 end
17 end
18 end
19
20 class Clock
a2af08d This commit was generated by cvs2svn to compensate for changes in r372,
matz authored
21 def initialize(tick)
22 @tick = tick
99d0354 Initial revision
matz authored
23 @tick.add_observer(self)
24 end
a2af08d This commit was generated by cvs2svn to compensate for changes in r372,
matz authored
25 def update(h, m, s)
26 printf "\e[8D%02d:%02d:%02d", h, m, s
99d0354 Initial revision
matz authored
27 STDOUT.flush
28 end
29 end
30
a2af08d This commit was generated by cvs2svn to compensate for changes in r372,
matz authored
31 clock = Clock.new(Tick.new)
99d0354 Initial revision
matz authored
32 sleep
Something went wrong with that request. Please try again.