diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-10-17 14:05:19 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-10-17 14:05:19 +0000 |
commit | 33a5b3bb84216e31d93a293f9430aa6a13f60178 (patch) | |
tree | ed85a8f118dfd483e84dc92c8798019aa06c5524 /ext/tk/lib | |
parent | 75a539313778aae3a85d8439771a722be7f61c86 (diff) | |
download | ruby-33a5b3bb84216e31d93a293f9430aa6a13f60178.tar.gz ruby-33a5b3bb84216e31d93a293f9430aa6a13f60178.tar.xz ruby-33a5b3bb84216e31d93a293f9430aa6a13f60178.zip |
* ext/tk/lib/tk/timer.rb: TkTimer#start and restart accept a block
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@7053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib')
-rw-r--r-- | ext/tk/lib/tk/timer.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/ext/tk/lib/tk/timer.rb b/ext/tk/lib/tk/timer.rb index 27c40e57e..f3b6465f7 100644 --- a/ext/tk/lib/tk/timer.rb +++ b/ext/tk/lib/tk/timer.rb @@ -321,20 +321,25 @@ class TkTimer self 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) fail ArguemntError, "expect Integer or 'idle' for 1st argument" end + @init_sleep = sleep @init_proc = init_proc @init_args = init_args + @init_proc = b if !@init_proc && b @init_proc = proc{|*args| } if @init_sleep > 0 && !@init_proc self end - def start(*init_args) + def start(*init_args, &b) return nil if @running Tk_CBTBL[@id] = self @@ -357,6 +362,7 @@ class TkTimer @init_proc = init_args.shift if argc > 1 @init_args = init_args if argc > 2 + @init_proc = b if !@init_proc && b @init_proc = proc{|*args| } if @init_sleep > 0 && !@init_proc @current_sleep = @init_sleep @@ -391,12 +397,12 @@ class TkTimer self end - def restart(*restart_args) + def restart(*restart_args, &b) cancel if @running - if restart_args == [] + if restart_args == [] && !b start(@init_sleep, @init_proc, *@init_args) else - start(*restart_args) + start(*restart_args, &b) end end |