Class: RTM::Task
- Inherits:
-
Object
- Object
- RTM::Task
- Includes:
- Test::Unit::Assertions
- Defined in:
- lib/rtmilk/api/tasks.rb
Overview
Task class. Unfortunately, RTM API defines this object as TaskSeries. That seemes to be unnatural.
Instance Attribute Summary collapse
-
#chunks ⇒ Object
readonly
Returns the value of attribute chunks.
-
#list ⇒ Object
readonly
Returns the value of attribute list.
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
Class Method Summary collapse
-
.find(arg) ⇒ Object
find a Task by name.
-
.find_all(arg) ⇒ Object
find all tasks by list, and name.
Instance Method Summary collapse
- #addNote(arg) ⇒ Object
- #created ⇒ Object
-
#delete ⇒ Object
delete a Task and its all chunks.
- #id ⇒ Object
-
#initialize(arg) ⇒ Task
constructor
create a Task.
- #modified ⇒ Object
- #name ⇒ Object
- #participants ⇒ Object
- #source ⇒ Object
- #tags ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(arg) ⇒ Task
create a Task.
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/rtmilk/api/tasks.rb', line 111 def initialize(arg) assert_equal(Hash, arg.class) @list = if arg.has_key? :list arg[:list] else RTM::List.inbox['id'] end if arg.has_key? :name # create from scratch result,transaction = RTM::Tasks::Add.new( RTM::API.token, RTM::Timeline.new(RTM::API.token).to_s, @list, arg[:name]).invoke @taskseries = result['taskseries'].first assert(@list, result['id']) create_chunks @notes = [] else assert(arg.has_key?(:taskseries)) @taskseries = arg[:taskseries] create_chunks create_notes end end |
Instance Attribute Details
#chunks ⇒ Object (readonly)
Returns the value of attribute chunks.
62 63 64 |
# File 'lib/rtmilk/api/tasks.rb', line 62 def chunks @chunks end |
#list ⇒ Object (readonly)
Returns the value of attribute list.
62 63 64 |
# File 'lib/rtmilk/api/tasks.rb', line 62 def list @list end |
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
62 63 64 |
# File 'lib/rtmilk/api/tasks.rb', line 62 def notes @notes end |
Class Method Details
.find(arg) ⇒ Object
find a Task by name.
76 77 78 79 80 |
# File 'lib/rtmilk/api/tasks.rb', line 76 def Task.find(arg) all_tasks(arg[:list]).find do |task| task.name =~ /#{arg[:name]}/ end end |
.find_all(arg) ⇒ Object
find all tasks by list, and name
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/rtmilk/api/tasks.rb', line 83 def Task.find_all(arg) tasks = all_tasks(arg[:list]) if arg.has_key? :name tasks.find_all do |task| task['name'] =~ /#{arg[:name]}/ end else tasks end end |
Instance Method Details
#addNote(arg) ⇒ Object
142 143 144 145 146 147 148 149 150 |
# File 'lib/rtmilk/api/tasks.rb', line 142 def addNote(arg) assert_equal(Hash, arg.class) n = RTM::Note.new( :task => self, :title => arg[:title], :body => arg[:body]) @notes.push n end |
#created ⇒ Object
72 |
# File 'lib/rtmilk/api/tasks.rb', line 72 def created; @taskseries['created']; end |
#delete ⇒ Object
delete a Task and its all chunks.
138 139 140 |
# File 'lib/rtmilk/api/tasks.rb', line 138 def delete chunks.collect { |chunk| chunk.delete(id, @list) } end |
#id ⇒ Object
67 |
# File 'lib/rtmilk/api/tasks.rb', line 67 def id; @taskseries['id']; end |
#modified ⇒ Object
68 |
# File 'lib/rtmilk/api/tasks.rb', line 68 def modified; @taskseries['modified']; end |
#name ⇒ Object
66 |
# File 'lib/rtmilk/api/tasks.rb', line 66 def name; @taskseries['name']; end |
#participants ⇒ Object
70 |
# File 'lib/rtmilk/api/tasks.rb', line 70 def participants; @taskseries['participants']; end |
#source ⇒ Object
73 |
# File 'lib/rtmilk/api/tasks.rb', line 73 def source; @taskseries['source']; end |
#tags ⇒ Object
69 |
# File 'lib/rtmilk/api/tasks.rb', line 69 def ; @taskseries['tags']; end |
#url ⇒ Object
71 |
# File 'lib/rtmilk/api/tasks.rb', line 71 def url; @taskseries['url']; end |