Class: Wunderlist::Task
- Inherits:
-
Object
- Object
- Wunderlist::Task
- Includes:
- Helper
- Defined in:
- lib/wunderlist/task.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
-
#assignee_id ⇒ Object
Returns the value of attribute assignee_id.
-
#completed ⇒ Object
Returns the value of attribute completed.
-
#completed_at ⇒ Object
Returns the value of attribute completed_at.
-
#completed_by_id ⇒ Object
Returns the value of attribute completed_by_id.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#due_date ⇒ Object
Returns the value of attribute due_date.
-
#id ⇒ Object
Returns the value of attribute id.
-
#list_id ⇒ Object
Returns the value of attribute list_id.
-
#recurrence_count ⇒ Object
Returns the value of attribute recurrence_count.
-
#recurrence_type ⇒ Object
Returns the value of attribute recurrence_type.
-
#revision ⇒ Object
Returns the value of attribute revision.
-
#starred ⇒ Object
Returns the value of attribute starred.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ Task
constructor
A new instance of Task.
- #new_subtask(attrs = {}) ⇒ Object
- #new_task_comment(attrs = {}) ⇒ Object
- #note ⇒ Object
- #reminder ⇒ Object
- #subtasks ⇒ Object
- #task_comments ⇒ Object
Methods included from Helper
#create, #destroy, #model_name, #path, #plural_model_name, #resource_path, #save, #to_hash, #update
Constructor Details
#initialize(attrs = {}) ⇒ Task
Returns a new instance of Task.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/wunderlist/task.rb', line 14 def initialize(attrs = {}) @api = attrs['api'] @id = attrs['id'] @list_id = attrs['list_id'] @title = attrs['title'] @revision = attrs['revision'] @assignee_id = attrs['assignee_id'] @completed = attrs['completed'] @completed_at = attrs['completed_at'] @completed_by_id = attrs['completed_by_id'] @recurrence_type = attrs['recurrence_type'] @recurrence_count = attrs['recurrence_count'] @due_date = attrs['due_date'] @starred = attrs['starred'] end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
12 13 14 |
# File 'lib/wunderlist/task.rb', line 12 def api @api end |
#assignee_id ⇒ Object
Returns the value of attribute assignee_id.
12 13 14 |
# File 'lib/wunderlist/task.rb', line 12 def assignee_id @assignee_id end |
#completed ⇒ Object
Returns the value of attribute completed.
12 13 14 |
# File 'lib/wunderlist/task.rb', line 12 def completed @completed end |
#completed_at ⇒ Object
Returns the value of attribute completed_at.
12 13 14 |
# File 'lib/wunderlist/task.rb', line 12 def completed_at @completed_at end |
#completed_by_id ⇒ Object
Returns the value of attribute completed_by_id.
12 13 14 |
# File 'lib/wunderlist/task.rb', line 12 def completed_by_id @completed_by_id end |
#created_at ⇒ Object
Returns the value of attribute created_at.
12 13 14 |
# File 'lib/wunderlist/task.rb', line 12 def created_at @created_at end |
#due_date ⇒ Object
Returns the value of attribute due_date.
12 13 14 |
# File 'lib/wunderlist/task.rb', line 12 def due_date @due_date end |
#id ⇒ Object
Returns the value of attribute id.
12 13 14 |
# File 'lib/wunderlist/task.rb', line 12 def id @id end |
#list_id ⇒ Object
Returns the value of attribute list_id.
12 13 14 |
# File 'lib/wunderlist/task.rb', line 12 def list_id @list_id end |
#recurrence_count ⇒ Object
Returns the value of attribute recurrence_count.
12 13 14 |
# File 'lib/wunderlist/task.rb', line 12 def recurrence_count @recurrence_count end |
#recurrence_type ⇒ Object
Returns the value of attribute recurrence_type.
12 13 14 |
# File 'lib/wunderlist/task.rb', line 12 def recurrence_type @recurrence_type end |
#revision ⇒ Object
Returns the value of attribute revision.
12 13 14 |
# File 'lib/wunderlist/task.rb', line 12 def revision @revision end |
#starred ⇒ Object
Returns the value of attribute starred.
12 13 14 |
# File 'lib/wunderlist/task.rb', line 12 def starred @starred end |
#title ⇒ Object
Returns the value of attribute title.
12 13 14 |
# File 'lib/wunderlist/task.rb', line 12 def title @title end |
Instance Method Details
#new_subtask(attrs = {}) ⇒ Object
84 85 86 87 88 89 90 91 92 |
# File 'lib/wunderlist/task.rb', line 84 def new_subtask(attrs = {}) attrs.stringify_keys s_t = Wunderlist::Subtask.new(attrs) s_t.api = self.api s_t.task_id = self.id s_t end |
#new_task_comment(attrs = {}) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/wunderlist/task.rb', line 44 def new_task_comment(attrs = {}) attrs.stringify_keys t_c = Wunderlist::TaskComment.new(attrs) t_c.api = self.api t_c.task_id = self.id t_c end |
#note ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/wunderlist/task.rb', line 54 def note res = self.api.request :get, 'api/v1/notes', {:task_id => self.id} if !res[0].nil? note = Wunderlist::Note.new(res[0]) else note = Wunderlist::Note.new('task_id' => self.id) end note.api = self.api note.task_id = self.id note end |
#reminder ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/wunderlist/task.rb', line 69 def reminder res = self.api.request :get, 'api/v1/reminders', {:task_id => self.id} if !res[0].nil? reminder = Wunderlist::Rminder.new(res[0]) else reminder = Wunderlist::Reminder.new('task_id' => self.id) end reminder.api = self.api reminder.task_id = self.id reminder end |
#subtasks ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/wunderlist/task.rb', line 94 def subtasks res = self.api.request :get, 'api/v1/subtasks', {:task_id => self.id} subtasks = [] res.each do |r| subtask = Wunderlist::Subtask.new(r) subtask.api = self subtasks << subtask end subtasks end |
#task_comments ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/wunderlist/task.rb', line 30 def task_comments res = self.api.request :get, 'api/v1/task_comments', {:task_id => self.id} task_comments = [] res.each do |t_c| task_comment = Wunderlist::TaskComment.new(t_c) task_comment.api = self.api task_comments << task_comment end task_comments end |