Module: RruleUtils
- Defined in:
- lib/recurable/rrule_utils.rb
Instance Method Summary collapse
- #humanize_recurrence ⇒ Object
- #last_recurrence_time_before(before, dt_start_at:) ⇒ Object
- #next_recurrence_time_after(after, dt_start_at:) ⇒ Object
- #recurrence_times(project_from:, project_to:, dt_start_at: nil) ⇒ Object
Instance Method Details
#humanize_recurrence ⇒ Object
25 26 27 |
# File 'lib/recurable/rrule_utils.rb', line 25 def humanize_recurrence RRule::Rule.new(recurrence.to_rrule).humanize end |
#last_recurrence_time_before(before, dt_start_at:) ⇒ Object
15 16 17 18 |
# File 'lib/recurable/rrule_utils.rb', line 15 def last_recurrence_time_before(before, dt_start_at:) project_from = (Recurrence::FREQUENCIES[recurrence.frequency] * recurrence.interval).days.ago(before) recurrence_times(project_from:, project_to: before, dt_start_at:).last end |
#next_recurrence_time_after(after, dt_start_at:) ⇒ Object
20 21 22 23 |
# File 'lib/recurable/rrule_utils.rb', line 20 def next_recurrence_time_after(after, dt_start_at:) project_to = (Recurrence::FREQUENCIES[recurrence.frequency] * recurrence.interval).days.since(after) recurrence_times(project_from: after, project_to:, dt_start_at:).first end |
#recurrence_times(project_from:, project_to:, dt_start_at: nil) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/recurable/rrule_utils.rb', line 8 def recurrence_times(project_from:, project_to:, dt_start_at: nil) dt_start_at ||= project_from RRule::Rule.new(recurrence.to_rrule, dtstart: dt_start_at, tzid: Time.zone.tzinfo.identifier) .between(project_from, project_to) .uniq end |