Method: RTM::Note#initialize

Defined in:
lib/rtmilk/api/notes.rb

#initialize(arg) ⇒ Note

Returns a new instance of Note.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# 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