Class: TimeLine::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/arbi/timeline.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ev = 2, to = 5, &blk) ⇒ Job

Returns a new instance of Job.



27
28
29
30
31
32
33
# File 'lib/arbi/timeline.rb', line 27

def initialize(ev = 2, to = 5, &blk)
  self.every = ev
  self.timeout = to
  self.proc = blk

  TimeLine.register(self)
end

Instance Attribute Details

#everyObject

Returns the value of attribute every.



25
26
27
# File 'lib/arbi/timeline.rb', line 25

def every
  @every
end

#procObject

Returns the value of attribute proc.



25
26
27
# File 'lib/arbi/timeline.rb', line 25

def proc
  @proc
end

#timeoutObject

Returns the value of attribute timeout.



25
26
27
# File 'lib/arbi/timeline.rb', line 25

def timeout
  @timeout
end

Instance Method Details

#runObject



50
51
52
53
54
55
56
# File 'lib/arbi/timeline.rb', line 50

def run
  EventMachine::PeriodicTimer.new(self.every) {
    ::Timeout.timeout(self.timeout) {
      self.proc.call
    }
  }
end