class RTM::Task
Task
class. Unfortunately, RTM
API
defines this object as TaskSeries. That seemes to be unnatural.
Attributes
chunks[R]
list[R]
notes[R]
Public Class Methods
find(arg)
click to toggle source
find a Task
by name.
# 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)
click to toggle source
find all tasks by list, and name
# 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
new(arg)
click to toggle source
create a Task
.
# 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
Private Class Methods
all_tasks(list = nil)
click to toggle source
# File lib/rtmilk/api/tasks.rb, line 95 def Task.all_tasks(list = nil) result = RTM::Tasks::GetList.new(RTM::API.token, list).invoke ret = [] result.each do |x| if x.has_key? 'taskseries' x['taskseries'].each do |y| ret.push Task.new(:taskseries => y, :list => x['id']) end end end ret end
Public Instance Methods
addNote(arg)
click to toggle source
# 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()
click to toggle source
# File lib/rtmilk/api/tasks.rb, line 72 def created; @taskseries['created']; end
delete()
click to toggle source
delete a Task
and its all chunks.
# File lib/rtmilk/api/tasks.rb, line 138 def delete chunks.collect { |chunk| chunk.delete(id, @list) } end
id()
click to toggle source
# File lib/rtmilk/api/tasks.rb, line 67 def id; @taskseries['id']; end
modified()
click to toggle source
# File lib/rtmilk/api/tasks.rb, line 68 def modified; @taskseries['modified']; end
name()
click to toggle source
# File lib/rtmilk/api/tasks.rb, line 66 def name; @taskseries['name']; end
participants()
click to toggle source
# File lib/rtmilk/api/tasks.rb, line 70 def participants; @taskseries['participants']; end
source()
click to toggle source
# File lib/rtmilk/api/tasks.rb, line 73 def source; @taskseries['source']; end
url()
click to toggle source
# File lib/rtmilk/api/tasks.rb, line 71 def url; @taskseries['url']; end
Private Instance Methods
create_chunks()
click to toggle source
# File lib/rtmilk/api/tasks.rb, line 153 def create_chunks @chunks = [] @taskseries['task'].each do |t| @chunks.push Chunk.new(t) end end
create_notes()
click to toggle source
# File lib/rtmilk/api/tasks.rb, line 160 def create_notes @notes = [] assert_equal(Array, @taskseries['notes'].class) assert_equal(Hash, @taskseries['notes'].first.class) if @taskseries['notes'].first.has_key? 'note' @taskseries['notes'].first['note'].each do |n| @notes.push Note.new(:hash => n) end end end