Sha256: 0cfda40ece66fc5ba4f31faccc53d6f9d4c9f02daa8ebf5f99cc816022dba6b2

Contents?: true

Size: 1.09 KB

Versions: 11

Compression:

Stored size: 1.09 KB

Contents

require 'rufus/scheduler'

module Spider; module Worker
    
    
    class Runner
        
        def initialize
            if Gem.loaded_specs['rufus-scheduler'].version.to_s < "3.0.0"
                @scheduler = Rufus::Scheduler.start_new
            else
                @scheduler = Rufus::Scheduler.new
            end
        end
        
        def stop
            @scheduler.stop
        end
        
        def join
            @scheduler.join
        end
        
        def every(time, params=nil, &proc)
            if (params)
                @scheduler.every(time) do
                    params[:obj].send(params[:method], *params[:arguments])
                end
            else
                @scheduler.every(time, &proc)
            end
        end
        
        def cron(time, params=nil, &proc)
            if (params)
                @scheduler.cron(time) do
                    params[:obj].send(params[:method], *params[:arguments])
                end
            else
                @scheduler.cron(time, &proc)
            end
        end
        
    end
    
    
end; end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
spiderfw-1.0.1 apps/worker/lib/runner.rb
spiderfw-1.0.0 apps/worker/lib/runner.rb
spiderfw-0.6.39 apps/worker/lib/runner.rb
spiderfw-0.6.38 apps/worker/lib/runner.rb
spiderfw-0.6.37 apps/worker/lib/runner.rb
spiderfw-0.6.35 apps/worker/lib/runner.rb
spiderfw-0.6.34 apps/worker/lib/runner.rb
spiderfw-0.6.33 apps/worker/lib/runner.rb
spiderfw-0.6.32 apps/worker/lib/runner.rb
spiderfw-0.6.31 apps/worker/lib/runner.rb
spiderfw-0.6.30 apps/worker/lib/runner.rb