зеркало из https://github.com/github/ruby.git
* ext/tk/lib/tk/timer.rb: TkTimer#start and restart accept a block
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
fa420ca48a
Коммит
6fb00e8a1f
|
@ -1,3 +1,7 @@
|
||||||
|
Sun Oct 17 23:03:48 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||||
|
|
||||||
|
* ext/tk/lib/tk/timer.rb: TkTimer#start and restart accept a block
|
||||||
|
|
||||||
Sun Oct 17 12:53:46 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
Sun Oct 17 12:53:46 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||||
|
|
||||||
* ext/win32ole/win32ole.c (fole_func_methods): correct argument mismatch.
|
* ext/win32ole/win32ole.c (fole_func_methods): correct argument mismatch.
|
||||||
|
|
|
@ -321,20 +321,25 @@ class TkTimer
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_start_proc(sleep, init_proc=nil, *init_args)
|
def set_start_proc(sleep=nil, init_proc=nil, *init_args, &b)
|
||||||
|
# set parameters for 'restart'
|
||||||
|
sleep = @init_sleep unless sleep
|
||||||
|
|
||||||
if !sleep == 'idle' && !sleep.kind_of?(Integer)
|
if !sleep == 'idle' && !sleep.kind_of?(Integer)
|
||||||
fail ArguemntError, "expect Integer or 'idle' for 1st argument"
|
fail ArguemntError, "expect Integer or 'idle' for 1st argument"
|
||||||
end
|
end
|
||||||
|
|
||||||
@init_sleep = sleep
|
@init_sleep = sleep
|
||||||
@init_proc = init_proc
|
@init_proc = init_proc
|
||||||
@init_args = init_args
|
@init_args = init_args
|
||||||
|
|
||||||
|
@init_proc = b if !@init_proc && b
|
||||||
@init_proc = proc{|*args| } if @init_sleep > 0 && !@init_proc
|
@init_proc = proc{|*args| } if @init_sleep > 0 && !@init_proc
|
||||||
|
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def start(*init_args)
|
def start(*init_args, &b)
|
||||||
return nil if @running
|
return nil if @running
|
||||||
|
|
||||||
Tk_CBTBL[@id] = self
|
Tk_CBTBL[@id] = self
|
||||||
|
@ -357,6 +362,7 @@ class TkTimer
|
||||||
@init_proc = init_args.shift if argc > 1
|
@init_proc = init_args.shift if argc > 1
|
||||||
@init_args = init_args if argc > 2
|
@init_args = init_args if argc > 2
|
||||||
|
|
||||||
|
@init_proc = b if !@init_proc && b
|
||||||
@init_proc = proc{|*args| } if @init_sleep > 0 && !@init_proc
|
@init_proc = proc{|*args| } if @init_sleep > 0 && !@init_proc
|
||||||
|
|
||||||
@current_sleep = @init_sleep
|
@current_sleep = @init_sleep
|
||||||
|
@ -391,12 +397,12 @@ class TkTimer
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def restart(*restart_args)
|
def restart(*restart_args, &b)
|
||||||
cancel if @running
|
cancel if @running
|
||||||
if restart_args == []
|
if restart_args == [] && !b
|
||||||
start(@init_sleep, @init_proc, *@init_args)
|
start(@init_sleep, @init_proc, *@init_args)
|
||||||
else
|
else
|
||||||
start(*restart_args)
|
start(*restart_args, &b)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче