Class: Things::Todo

Inherits:
Reference::Record show all
Defined in:
lib/things/todo.rb

Overview

Things::Todo

Instance Attribute Summary

Attributes inherited from Reference::Base

#reference

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Reference::Record

build, collection, convert, create, #delete, find, find_by_id, find_by_name, identifier, #initialize, #new?, properties, #save

Methods included from Reference::Inheritance

#inheritable_attributes, #inherited

Constructor Details

This class inherits a constructor from Things::Reference::Record

Class Method Details

.activeObject

Get all not completed Todos Note this returns an array of Todos, not references TODO: find a better way of filtering references



83
84
85
86
87
88
# File 'lib/things/todo.rb', line 83

def active
  result = (reference.get - Things::List.trash.reference.todos.get).select do |todo| 
    todo.completion_date.get == :missing_value
  end
  convert(result.compact)
end

.allObject

Returns an array of Things::Todo objects



76
77
78
# File 'lib/things/todo.rb', line 76

def all
  convert(reference.get)
end

.referenceObject

Returns an Appscript Reference to the entire collection of todos



62
63
64
# File 'lib/things/todo.rb', line 62

def reference
  Things::App.instance.todos
end

Instance Method Details

#completeObject

Set the status to :completed

Does not save the Todo



21
22
23
# File 'lib/things/todo.rb', line 21

def complete
  self.status = :completed
end

#complete!Object

Set the status to :completed

Saves the Todo



28
29
30
31
# File 'lib/things/todo.rb', line 28

def complete!
  complete
  self.save
end

#completed?Boolean

Check whether the Todo is completed or not

Returns:

  • (Boolean)


34
35
36
# File 'lib/things/todo.rb', line 34

def completed?
  self.status == :completed
end

#move(list) ⇒ Object

Move a todo to a different list <br /> Moving to Trash will delete the todo



13
14
15
16
# File 'lib/things/todo.rb', line 13

def move(list)
  list = list.reference if !list.is_a?(Appscript::Reference)
  Things::App.instance.move(reference, { :to => list })
end

#openObject

Set the status to :open

Does not save the Todo



41
42
43
# File 'lib/things/todo.rb', line 41

def open
  self.status = :open
end

#open!Object

Set the status to :open

Saves the Todo



48
49
50
51
# File 'lib/things/todo.rb', line 48

def open!
  open
  self.save
end

#open?Boolean

Check whether the Todo is open or not

Returns:

  • (Boolean)


54
55
56
# File 'lib/things/todo.rb', line 54

def open?
  self.status == :open
end