All pastes #447682 Raw Edit

hisham

public ruby v1 · immutable
·published 2007-04-19 07:05 UTC
rendered paste body
class Timers  def initialize    methods.grep /^timer_(\d+)/ do |m|      puts "found timer to add, [:meth => #{m}, :delay => #{$1}]"      # [TODO] hook up timer and delay into main event loop.      self.send m    end  endendclass MyTimers < Timers  # Add a timer that will tick every 4 seconds                                    def timer_4                                                                       puts "timer 1"  end  # Add a timer that will tick every 2 seconds                                    def timer_2    puts "timer 2"  endendt = MyTimers.new