Class: ProconBypassMan::Scheduler::Schedule

Inherits:
Object
  • Object
show all
Defined in:
lib/procon_bypass_man/scheduler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass:, args:, interval:) ⇒ Schedule

Returns a new instance of Schedule.

Parameters:

  • klass (any)
  • args (Array)
  • interval (Integer)


9
10
11
12
13
14
# File 'lib/procon_bypass_man/scheduler.rb', line 9

def initialize(klass: , args: , interval: )
  self.klass = klass
  self.args = args
  self.interval = interval
  self.next_enqueue_at = Time.now
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



4
5
6
# File 'lib/procon_bypass_man/scheduler.rb', line 4

def args
  @args
end

#intervalObject

Returns the value of attribute interval.



4
5
6
# File 'lib/procon_bypass_man/scheduler.rb', line 4

def interval
  @interval
end

#klassObject

Returns the value of attribute klass.



4
5
6
# File 'lib/procon_bypass_man/scheduler.rb', line 4

def klass
  @klass
end

#next_enqueue_atObject

Returns the value of attribute next_enqueue_at.



4
5
6
# File 'lib/procon_bypass_man/scheduler.rb', line 4

def next_enqueue_at
  @next_enqueue_at
end

Instance Method Details

#enqueuevoid

This method returns an undefined value.



17
18
19
20
# File 'lib/procon_bypass_man/scheduler.rb', line 17

def enqueue
  klass.perform_async(*unwrap_args(args))
  set_next_enqueue_at!
end

#past_interval?boolean

Returns:

  • (boolean)


23
24
25
# File 'lib/procon_bypass_man/scheduler.rb', line 23

def past_interval?
  next_enqueue_at < Time.now
end