Class: TodoNotifier

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTodoNotifier

Returns a new instance of TodoNotifier.


15
16
17
# File 'lib/todoNotifier.rb', line 15

def initialize()
  self.tl = TaskList.new
end

Instance Attribute Details

#tlObject

Returns the value of attribute tl.


10
11
12
# File 'lib/todoNotifier.rb', line 10

def tl
  @tl
end

Instance Method Details

#inRange(a, b, r) ⇒ Object


11
12
13
# File 'lib/todoNotifier.rb', line 11

def inRange(a, b, r)
  (((a.to_time - r).to_datetime < b) && ((a.to_time + r).to_datetime > b))
end

#updateObject


19
20
21
22
23
24
25
26
27
# File 'lib/todoNotifier.rb', line 19

def update()
  if self.tl.tasks[0]._d != nil
    if inRange(self.tl.tasks[0]._d, DateTime.now, 60)
      self.tl.tasks[0].notify()
      self.tl.tasks.shift
    end
  end
  sleep 60
end