class RTM::Note

a Note.

belongs to Task (TaskSeries).

usage:

Public Class Methods

new(arg) click to toggle source
# File lib/rtmilk/api/notes.rb, line 76
def initialize(arg)
   assert_equal(Hash, arg.class)

   if arg.has_key? :hash # already constructed
      @hash = arg[:hash]
   else # from scratch
      assert(arg.has_key?(:task))
      assert_equal(RTM::Task, arg[:task].class)
      assert(arg.has_key?(:title))
      assert(arg.has_key?(:body))

      @hash, transaction = RTM::Tasks::Notes::Add.new(
         RTM::API.token, 
         RTM::Timeline.new(RTM::API.token).to_s,
         arg[:task].list, arg[:task].id,
         arg[:task].chunks.first.id, # XXX: Note belongs to TaskSeries, why need Task id ?
         arg[:title],
         arg[:body]).invoke
   end
end
update(arg) click to toggle source
# File lib/rtmilk/api/notes.rb, line 130
def Note.update(arg)
   ret, transaction = RTM::Tasks::Notes::Edit.new(
      RTM::API.token, 
      RTM::Timeline.new(RTM::API.token).to_s,
      arg[:id],
      arg[:title],
      arg[:body]).invoke
end

Public Instance Methods

body() click to toggle source
# File lib/rtmilk/api/notes.rb, line 73
def body; @hash['content']; end
body=(text) click to toggle source

alter body field.

# File lib/rtmilk/api/notes.rb, line 110
def body=(text)
   ret, transaction = RTM::Tasks::Notes::Edit.new(
      RTM::API.token, 
      RTM::Timeline.new(RTM::API.token).to_s,
      id,
      title,
      text).invoke
   assert(ret['id'], id)
   @hash['content'] = text
end
created() click to toggle source
# File lib/rtmilk/api/notes.rb, line 74
def created; @hash['created']; end
delete() click to toggle source

delete this note. after deleted, should not touch this object.

# File lib/rtmilk/api/notes.rb, line 123
def delete
   RTM::Tasks::Notes::Delete.new(
      RTM::API.token, 
      RTM::Timeline.new(RTM::API.token).to_s,
      id).invoke
end
id() click to toggle source
# File lib/rtmilk/api/notes.rb, line 70
def id; @hash['id']; end
modified() click to toggle source
# File lib/rtmilk/api/notes.rb, line 72
def modified; @hash['modified']; end
title() click to toggle source
# File lib/rtmilk/api/notes.rb, line 71
def title; @hash['title']; end
title=(text) click to toggle source

alter title field.

# File lib/rtmilk/api/notes.rb, line 98
def title=(text)
   ret, transaction = RTM::Tasks::Notes::Edit.new(
      RTM::API.token, 
      RTM::Timeline.new(RTM::API.token).to_s,
      id,
      text,
      body).invoke
   assert(ret['id'], id)
   @hash['title'] = text
end