368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
|
# File 'lib/tk/timer.rb', line 368
def start(*init_args, &b)
return nil if @running
Tk_CBTBL[@id] = self
@do_loop = @loop_exec
@current_pos = 0
@return_value = nil
@after_id = nil
@init_sleep = 0
@init_proc = nil
@init_args = nil
argc = init_args.size
if argc > 0
sleep = init_args.shift
if sleep != 'idle' && sleep != :idle && !sleep.kind_of?(Integer)
fail ArgumentError, "expect Integer or 'idle' for 1st argument"
end
@init_sleep = sleep
end
@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
@running = true
if @init_proc
if !TkComm._callback_entry?(@init_proc)
fail ArgumentError, "Argument '#{@init_proc}' need to be Proc"
end
@current_proc = @init_proc
set_callback(@init_sleep, @init_args)
@set_next = false if @in_callback
else
set_next_callback(@init_args)
end
self
end
|