Extends gem ice_cube to handle custom rules, outside of the iCalendar spec.
First require ice_cube, and then require ice_cube_ex, by adding the following line to your application's Gemfile:
gem 'ice_cube'
gem 'ice_cube_ex'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ice_cube_ex
ice_cube_ex has new rules that can be used with ice_cube's schedules:
This rule allows to specify a number of days, which indicates a cycle, and another number of days to skip inside that cycle. For example, we want an event that starts at 2015-1-1 to recur every 5 days while skipping the last 3 days, we would do something like this:
schedule = IceCube::Schedule.new(Time.new(2015, 1, 1)) do |s|
s.rrule IceCubeEx::Rule.day_cycle(5, 3)
end
Now try calculating next occurrences:
occurrence_time = schedule.next_occurrence(Time.new(2014-12-30))
# returns 2015-1-1
occurrence_time = schedule.next_occurrence(occurrence_time)
# returns 2015-1-2
occurrence_time = schedule.next_occurrence(occurrence_time)
# returns 2015-1-3
occurrence_time = schedule.next_occurrence(occurrence_time)
# returns 2015-1-6
occurrence_time = schedule.next_occurrence(occurrence_time)
# returns 2015-1-7
occurrence_time = schedule.next_occurrence(occurrence_time)
# returns 2015-1-8
You can also use count and until to limit your rule as you would normally do with a regular ice_cube rule.
- Fork it ( https://github.com/junhanamaki/ice_cube_ex/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request