Class: Scheduler::Event

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

Overview

Represents an event which has been submitted to the scheduler (e.g. via Scheduler.at_time); the Event#cancel method may be used to cancel the event’s execution

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time, &proc) ⇒ Event

:nodoc:



24
25
26
27
# File 'lib/scheduler.rb', line 24

def initialize( time, &proc ) #:nodoc:
  @time = time
  @proc = proc
end

Instance Attribute Details

#timeObject (readonly)

:nodoc:



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

def time
  @time
end

Instance Method Details

#<=>(other) ⇒ Object

:nodoc:



44
45
46
# File 'lib/scheduler.rb', line 44

def <=>( other ) #:nodoc:
  @time <=> other.time
end

#cancelObject

Cancels the execution of the event represented by self if it has not already begun execution



39
40
41
42
# File 'lib/scheduler.rb', line 39

def cancel
  Scheduler.cancel self
  self
end

#runObject

:nodoc:



29
30
31
32
33
34
35
# File 'lib/scheduler.rb', line 29

def run #:nodoc:
  begin
    @proc.call
  rescue Exception
  end
  self
end