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.
536
537
538
539
|
# File 'lib/thartmx_lib.rb', line 536
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.
530
531
532
|
# File 'lib/thartmx_lib.rb', line 530
def rtm
@rtm
end
|
Instance Method Details
#<=>(other) ⇒ Object
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
|
# File 'lib/thartmx_lib.rb', line 572
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
549
|
# File 'lib/thartmx_lib.rb', line 549
def complete?() task[:completed] != '' end
|
#due ⇒ Object
545
|
# File 'lib/thartmx_lib.rb', line 545
def due() task.due end
|
#due_display ⇒ Object
558
559
560
561
562
563
564
565
566
567
568
|
# File 'lib/thartmx_lib.rb', line 558
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
547
|
# File 'lib/thartmx_lib.rb', line 547
def has_due?() due.class == Time end
|
#has_due_time? ⇒ Boolean
548
|
# File 'lib/thartmx_lib.rb', line 548
def has_due_time?() task.has_due_time == '1' end
|
#list_id ⇒ Object
544
|
# File 'lib/thartmx_lib.rb', line 544
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.
630
631
632
633
634
635
636
637
638
639
640
641
642
|
# File 'lib/thartmx_lib.rb', line 630
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
541
|
# File 'lib/thartmx_lib.rb', line 541
def task() tasks[-1] end
|
#task_id ⇒ Object
543
|
# File 'lib/thartmx_lib.rb', line 543
def task_id() self.has_key?(:task_id) ? self[:task_id] : task.rtm_id end
|
#taskseries_id ⇒ Object
542
|
# File 'lib/thartmx_lib.rb', line 542
def taskseries_id() self.has_key?(:taskseries_id) ? self[:taskseries_id] : rtm_id end
|
#timeline ⇒ Object
532
533
534
|
# File 'lib/thartmx_lib.rb', line 532
def timeline
@timeline ||= rtm.get_timeline end
|
#to_s ⇒ Object
550
551
552
553
554
555
556
|
# File 'lib/thartmx_lib.rb', line 550
def to_s
a_parent_list = self[:parent_list] || '<Parent Not Set>'
a_taskseries_id = self[:taskseries_id] || self[:id] || '<No Taskseries Id>'
a_task_id = self[:task_id] || (self[:task] && self[:task].rtm_td) || '<No Task Id>'
a_name = self[:name] || '<Name Not Set>'
"#{a_parent_list}/#{a_taskseries_id}/#{a_task_id}: #{a_name}"
end
|