Class: RememberTheMilkTask
Overview
The API is aware it’s creating tasks. You may want to add semantics to a “task” elsewhere in your program. This gives you that flexibility plus, we’ve added some helper methods
Constant Summary
collapse
- @@BeginningOfEpoch =
kludgey.. sure. life’s a kludge. deal with it.
Time.parse("Jan 1 1904")
Instance Attribute Summary collapse
Instance Method Summary
collapse
#arrayify_value, #id, #method_missing, #rtm_id, strict_keys=
Constructor Details
Returns a new instance of RememberTheMilkTask.
512
513
514
515
|
# File 'lib/rtmapi.rb', line 512
def initialize( rtm_api_handle=nil )
super
@rtm = rtm_api_handle end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class RememberTheMilkHash
Instance Attribute Details
#rtm ⇒ Object
Returns the value of attribute rtm.
506
507
508
|
# File 'lib/rtmapi.rb', line 506
def rtm
@rtm
end
|
Instance Method Details
#<=>(other) ⇒ Object
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
|
# File 'lib/rtmapi.rb', line 544
def <=>(other)
due = (has_key?(:tasks) && tasks.class == Array) ? task[:due] : nil
due = @@BeginningOfEpoch unless due.class == Time
other_due = (other.has_key?(:tasks) && other.tasks.class == Array) ? other.task[:due] : nil
other_due = @@BeginningOfEpoch unless other_due.class == Time
prio = priority.to_i
prio += 666 if prio == 0 other_prio = other.priority.to_i
other_prio += 666 if other_prio == 0
if prio != other_prio
return prio <=> other_prio
elsif due != other_due
return due <=> other_due
else
return self[:name].to_s <=> other[:name].to_s
end
end
|
#complete? ⇒ Boolean
525
|
# File 'lib/rtmapi.rb', line 525
def complete?() task[:completed] != '' end
|
#due ⇒ Object
521
|
# File 'lib/rtmapi.rb', line 521
def due() task.due end
|
#due_display ⇒ Object
530
531
532
533
534
535
536
537
538
539
540
|
# File 'lib/rtmapi.rb', line 530
def due_display
if has_due?
if has_due_time?
due.strftime("%a %d %b %y at %I:%M%p")
else
due.strftime("%a %d %b %y")
end
else
'[no due date]'
end
end
|
#has_due? ⇒ Boolean
523
|
# File 'lib/rtmapi.rb', line 523
def has_due?() due.class == Time end
|
#has_due_time? ⇒ Boolean
524
|
# File 'lib/rtmapi.rb', line 524
def has_due_time?() task.has_due_time == '1' end
|
#list_id ⇒ Object
520
|
# File 'lib/rtmapi.rb', line 520
def list_id() parent_list end
|
#moveTo(to_list_id, args = {}) ⇒ Object
We have to do this because moveTo takes a “from_list_id”, not “list_id”, so the above factory
wouldn't work. sigh.
601
602
603
604
605
606
607
608
609
610
611
612
613
|
# File 'lib/rtmapi.rb', line 601
def moveTo( to_list_id, args = {} )
if @rtm == nil
raise RememberTheMilkAPIError.new( :code => '667', :msg => "moveTO called without a handle to an rtm object [#{self.to_s}]" )
end
method_args = {}
method_args[:timeline] = timeline
method_args[:from_list_id] = list_id
method_args[:to_list_id] = to_list_id
method_args[:taskseries_id] = taskseries_id
method_args[:task_id] = task_id
method_args.merge( args )
@rtm.call_api_method( :moveTo, method_args )
end
|
#task ⇒ Object
517
|
# File 'lib/rtmapi.rb', line 517
def task() tasks[-1] end
|
#task_id ⇒ Object
519
|
# File 'lib/rtmapi.rb', line 519
def task_id() task.rtm_id end
|
#taskseries_id ⇒ Object
518
|
# File 'lib/rtmapi.rb', line 518
def taskseries_id() rtm_id end
|
#timeline ⇒ Object
508
509
510
|
# File 'lib/rtmapi.rb', line 508
def timeline
@timeline ||= rtm.get_timeline end
|
#to_s ⇒ Object
526
527
528
|
# File 'lib/rtmapi.rb', line 526
def to_s
"#{parent_list}/#{taskseries_id}/#{task_id}: #{name}"
end
|