Class: Things::Todo

Inherits:
Object
  • Object
show all
Defined in:
lib/teambox-things-sync.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#was_in_todayObject

Returns the value of attribute was_in_today.



23
24
25
# File 'lib/teambox-things-sync.rb', line 23

def was_in_today
  @was_in_today
end

Class Method Details

.find(name_or_id) ⇒ Object



38
39
40
41
42
# File 'lib/teambox-things-sync.rb', line 38

def self.find(name_or_id)
  todo = super
  todo.remember_today_listing if todo
  return todo
end

Instance Method Details

#move_to_today_if_necessaryObject

Moves todo to Today list if it’s due today or in the past, or user put it there manually



27
28
29
30
31
32
# File 'lib/teambox-things-sync.rb', line 27

def move_to_today_if_necessary
  tomorrow_midnight = Time.parse((Date.today+1).to_s)
  if (self.due_date && self.due_date < tomorrow_midnight) || was_in_today
    self.move(Things::List.today)
  end
end

#remember_today_listingObject



34
35
36
# File 'lib/teambox-things-sync.rb', line 34

def remember_today_listing
  @was_in_today = Things::Todo.today.any? {|t| t.name == self.name}
end

#saveObject



44
45
46
47
48
# File 'lib/teambox-things-sync.rb', line 44

def save
  todo = super
  todo.move_to_today_if_necessary if todo
  return todo
end