Class: Things::Todo
- Inherits:
-
Reference::Record
- Object
- Reference::Base
- Reference::Record
- Things::Todo
- Defined in:
- lib/things/todo.rb
Overview
Things::Todo
Instance Attribute Summary
Attributes inherited from Reference::Base
Class Method Summary collapse
-
.active ⇒ Object
Get all not completed Todos Note this returns an array of Todos, not references TODO: find a better way of filtering references.
-
.all ⇒ Object
Returns an array of Things::Todo objects.
-
.reference ⇒ Object
Returns an Appscript Reference to the entire collection of todos.
Instance Method Summary collapse
-
#complete ⇒ Object
Set the status to :completed.
-
#complete! ⇒ Object
Set the status to :completed.
-
#completed? ⇒ Boolean
Check whether the Todo is completed or not.
-
#move(list) ⇒ Object
Move a todo to a different list <br /> Moving to Trash will delete the todo.
-
#open ⇒ Object
Set the status to :open.
-
#open! ⇒ Object
Set the status to :open.
-
#open? ⇒ Boolean
Check whether the Todo is open or not.
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
.active ⇒ Object
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 |
.all ⇒ Object
Returns an array of Things::Todo objects
76 77 78 |
# File 'lib/things/todo.rb', line 76 def all convert(reference.get) end |
Instance Method Details
#complete ⇒ Object
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
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 |
#open ⇒ Object
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
54 55 56 |
# File 'lib/things/todo.rb', line 54 def open? self.status == :open end |