Class: Sculd::Plan::Deadline

Inherits:
Sculd::Plan show all
Defined in:
lib/sculd/plan/deadline.rb

Constant Summary collapse

SYMBOL_CHAR =
"!"
DEFAULT_OPTION =
7

Constants inherited from Sculd::Plan

DEADLINE_PRIORITY, REMINDER_PRIORITY

Instance Attribute Summary

Attributes inherited from Sculd::Plan

#datetime, #description, #flag_time, #option

Instance Method Summary collapse

Methods inherited from Sculd::Plan

#initialize, parse, wday

Constructor Details

This class inherits a constructor from Sculd::Plan

Instance Method Details

#event_datesObject



34
35
36
37
38
39
40
41
42
43
# File 'lib/sculd/plan/deadline.rb', line 34

def event_dates
  #@option ||= DEFAULT_OPTION

  results = []
  results << @datetime - (@option || DEFAULT_OPTION) unless @option == 0
  results << @datetime
  results.map do |datetime|
    Date.new(datetime.year, datetime.month, datetime.day)
  end
end

#priority(today) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sculd/plan/deadline.rb', line 15

def priority(today)
  #pp @option
  #@option = 1 if @option < 1
  option = (@option || DEFAULT_OPTION)
  beginning = @datetime - option
  #pp beginning
  if today < beginning
    return 0
  elsif today == @datetime
    return Sculd::Plan::DEADLINE_PRIORITY
  elsif today <= @datetime
    rp = Sculd::Plan::REMINDER_PRIORITY
    dp = Sculd::Plan::DEADLINE_PRIORITY
    return (rp + (dp - rp) * (today - beginning)/(option.to_f)).to_i
  else
    return Sculd::Plan::DEADLINE_PRIORITY
  end
end