Recurring events in Ruby
Modeling recurrence with the Montrose gem
At NYC.rb, I introduced Montrose
, a gem I created to model recurrence in Ruby.
Star this deck on SpeaderDeck.
Why would you need Montrose
? Well, a calendaring or scheduling application may reach a point where it needs to handle entries that repeat at predefined intervals; it may useful to have an abstraction to represent that recurrence. How would you handle "every Friday 13th, forever"? It wouldn't be feasible to generate infinite events upfront to represent each instance - Montrose
helps
you define and enumerate these recurrences on demand.
# Friday the 13th, forever
Montrose.monthly(on: { friday: 13 })
I also wrote plenty of examples using Montrose if you're interested to learn more.
Favorite the project on GitHub and fork it to contribute.