Class: CreateTask::DueApp

Inherits:
Object
  • Object
show all
Defined in:
lib/ExtraCare2OF/services.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ DueApp

include ‘helper’



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/ExtraCare2OF/services.rb', line 63

def initialize(args)
  name = args[:name]
  # due_date = parse_date(args[:due_date])
  due_date = args[:due_date]
  remind =%x{osascript << 'APPLESCRIPT'
             set d_date to date "#{due_date}"
             set theURl to "due:///add?title=#{name}&due_date=" & d_date
             tell application "Finder" to open location theURl
             tell application "Due" to activate
             delay 0.5 -- This delay can be tweaked for your system
             tell application "Due" to activate
             tell application "System Events" to key code 36
             delay 1 -- This delay can be tweaked for your system
             APPLESCRIPT
             }

end

Instance Method Details

#parse_date(datestring) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/ExtraCare2OF/services.rb', line 81

def parse_date(datestring)
  days = 0
  if datestring =~ /^\+(\d+)$/
    days = (60 * 60 * 24 * $1.to_i)
    newdate = Time.now + days
  else
    newdate = Chronic.parse(datestring, {:context => :future, :ambiguous_time_range => 8})
  end
  # parsed = newdate.strftime('%D %l:%M%p').gsub(/\s+/,' ');
  # return parsed =~ /1969/ ? false : parsed
  return newdate
end