lib/sculd/plan/deadline.rb in sculd-0.1.2 vs lib/sculd/plan/deadline.rb in sculd-0.1.3

- old
+ new

@@ -7,37 +7,39 @@ # # # class Sculd::Plan::Deadline < Sculd::Plan - SYMBOL_CHAR = "!" - DEFAULT_OPTION = 7 + SYMBOL_CHAR = "!" + DEFAULT_OPTION = 7 - 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 - 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 + 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 - end - def event_dates - #@option ||= DEFAULT_OPTION + def event_dates + #@option ||= DEFAULT_OPTION - results = [] - results << @datetime - (@option || DEFAULT_OPTION) - results << @datetime - results.map do |datetime| - Date.new(datetime.year, datetime.month, datetime.day) + 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 - end end