Class: SimpleKit::EventScheduler::EventNotice

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

Overview

This is a private helper class for the EventScheduler class. Users should never try to access this directly.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event, time, delay, args) ⇒ EventNotice

Returns a new instance of EventNotice.



139
140
141
142
143
144
145
# File 'lib/simplekit.rb', line 139

def initialize(event, time, delay, args)
  @event = event
  @time_stamp = time
  @time = time + delay
  @args = args
  @priority = @args && @args.key?(:priority) ? @args.delete(:priority) : 10
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



137
138
139
# File 'lib/simplekit.rb', line 137

def args
  @args
end

#eventObject (readonly)

Returns the value of attribute event.



137
138
139
# File 'lib/simplekit.rb', line 137

def event
  @event
end

#priorityObject (readonly)

Returns the value of attribute priority.



137
138
139
# File 'lib/simplekit.rb', line 137

def priority
  @priority
end

#timeObject (readonly)

Returns the value of attribute time.



137
138
139
# File 'lib/simplekit.rb', line 137

def time
  @time
end

#time_stampObject (readonly)

Returns the value of attribute time_stamp.



137
138
139
# File 'lib/simplekit.rb', line 137

def time_stamp
  @time_stamp
end

Instance Method Details

#<=>(other) ⇒ Object

Compare EventNotice objects for ordering, first by time, breaking ties using priority.



150
151
152
153
154
# File 'lib/simplekit.rb', line 150

def <=>(other)
  (time <=> other.time).tap do |outcome|
    return priority <=> other.priority if outcome == 0
  end
end