lib/perfectsched/client.rb
def add(key, type, options={})
      cron = options[:cron]

      raise ArgumentError, ":cron option is required" unless cron

      delay = options[:delay] || 0
      timezone = options[:timezone] || @timezone
      data = options[:data] || {}

      next_time = options[:next_time] || Time.now.to_i
      next_time = PerfectSched.cron_time(cron, next_time.to_i, timezone)

      next_run_time = options[:next_run_time]
      if next_run_time
        next_run_time = next_run_time.to_i
      else
        next_run_time = next_time + delay
      end

      @backend.add(key, type, cron, delay, timezone, data, next_time, next_run_time, options)

      # TODO return value
      return next_time, next_run_time
    end
def add(key, type, options={})
      cron = options[:cron]

      raise ArgumentError, ":cron option is required" unless cron

      delay = options[:delay] || 0
      timezone = options[:timezone] || @timezone
      data = options[:data] || {}

      next_time = options[:next_time] || Time.now.to_i
      next_time = PerfectSched.cron_time(cron, next_time.to_i, timezone)

      next_run_time = options[:next_run_time]
      if next_run_time
        next_run_time = next_run_time.to_i
      else
        next_run_time = next_time + delay
      end

      @backend.add(key, type, cron, delay, timezone, data, next_time, next_run_time, options)

      # TODO return value
      return next_time, next_run_time
    end
def add ( key , type , options = { } ) cron = options [ :cron ] raise ArgumentError , ":cron option is required" unless cron delay = options [ :delay ] || 0 timezone = options [ :timezone ] || @timezone data = options [ :data ] || { } next_time = options [ :next_time ] || Time . now . to_i next_time = PerfectSched . cron_time ( cron , next_time . to_i , timezone ) next_run_time = options [ :next_run_time ] if next_run_time next_run_time = next_run_time . to_i else next_run_time = next_time + delay end @backend . add ( key , type , cron , delay , timezone , data , next_time , next_run_time , options ) # TODO return value return next_time , next_run_time end
:next_time => Time.now
 :next_run_time => Time.now
 :cron
 :data
 :delay => 0
 :timezone => UTC
: next_time = > Time . now : next_run_time = > Time . now : cron : data : delay = > 0 : timezone = > UTC