Class: RecurringTodos::DailyRecurrencePattern
Instance Attribute Summary
#attributes
Instance Method Summary
collapse
#build_from_recurring_todo, #build_recurring_todo, #continues_recurring?, #day_of_week_as_text, #determine_start, #end_date, #ends_on, #errors, #find_last_day_x_of_month, #find_xth_day_of_month, #get, #get_due_date, #get_show_from_date, #get_xth_day_of_month, #month_of_year_as_text, #number_of_occurrences, #put_in_tickler?, #recurring_target_as_text, #set_recurrence_on_validations, #show_always?, #show_from_delta, #start_from, #starts_and_ends_on_validations, #target, #update_recurring_todo, #valid?, #validate_not_blank, #validate_not_nil, #xth
Constructor Details
Returns a new instance of DailyRecurrencePattern.
3
4
5
|
# File 'app/models/recurring_todos/daily_recurrence_pattern.rb', line 3
def initialize(user)
super user
end
|
Instance Method Details
#every_x_days ⇒ Object
7
8
9
|
# File 'app/models/recurring_todos/daily_recurrence_pattern.rb', line 7
def every_x_days
get :every_other1
end
|
#get_next_date(previous) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'app/models/recurring_todos/daily_recurrence_pattern.rb', line 30
def get_next_date(previous)
start = determine_start(previous, 1.day)
if only_work_days?
return start + 2.day if start.wday == 6 return start + 1.day if start.wday == 0 return start
else
return previous == nil ? start : start + every_x_days.day - 1.day
end
end
|
#only_work_days? ⇒ Boolean
11
12
13
|
# File 'app/models/recurring_todos/daily_recurrence_pattern.rb', line 11
def only_work_days?
get :only_work_days
end
|
#recurrence_pattern ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'app/models/recurring_todos/daily_recurrence_pattern.rb', line 15
def recurrence_pattern
if only_work_days?
I18n.t("todos.recurrence.pattern.on_work_days")
elsif every_x_days > 1
I18n.t("todos.recurrence.pattern.every_n_days", :n => every_x_days)
else
I18n.t("todos.recurrence.pattern.every_day")
end
end
|
#validate ⇒ Object
25
26
27
28
|
# File 'app/models/recurring_todos/daily_recurrence_pattern.rb', line 25
def validate
super
errors.add(:base, "Every other nth day may not be empty for this daily recurrence setting") if (!only_work_days?) && every_x_days.blank?
end
|