class Iup::Timer

Attributes

handle[R]

Public Class Methods

new(&block) click to toggle source
# File lib/wrapped/timer.rb, line 9
def initialize &block
  @handle = IupLib.IupTimer

  # run any provided block on instance, to set up further attributes
  self.instance_eval &block if block_given?
end

Public Instance Methods

action_cb(callback) click to toggle source

Called when the time is up. Return CLOSE to end application.

# File lib/wrapped/timer.rb, line 31
def action_cb callback
  unless callback.arity.zero?
    raise ArgumentError, 'action_cb must take 0 arguments'
  end
  cb = Proc.new do |ih|
    callback.call
  end
  define_callback cb, 'ACTION_CB', :plain
end
destroy() click to toggle source

must be called when Timer is finished with

# File lib/wrapped/timer.rb, line 17
def destroy
  IupLib.IupDestroy @handle
end