Module: Montrose::Chainable
- Included in:
- Montrose, Recurrence
- Defined in:
- lib/montrose/chainable.rb
Instance Method Summary collapse
-
#at(time) ⇒ Montrose::Recurrence
Create a recurrence at given time.
-
#between(date_range) ⇒ Montrose::Recurrence
Create a recurrence occurring between the start and end of a given date range; :between is shorthand for separate :starts and :until options.
- #branch(options) ⇒ Object
-
#covering(date_range) ⇒ Montrose::Recurrence
Create a recurrence which will only emit values within the date range, also called “masking.”.
-
#daily(options = {}) ⇒ Montrose::Recurrence
Create a daily recurrence.
-
#day_of_month(days, *extras) ⇒ Montrose::Recurrence
(also: #mday)
Create a recurrence for given days of month.
-
#day_of_week(weekdays, *extras) ⇒ Montrose::Recurrence
(also: #day)
Create a recurrence for given days of week.
-
#day_of_year(days, *extras) ⇒ Montrose::Recurrence
(also: #yday)
Create a recurrence for given days of year.
- #default_options ⇒ Object
-
#during(time_of_day, *extras) ⇒ Montrose::Recurrence
Create a recurrence occurring within a time-of-day range or ranges.
-
#every(frequency, options = {}) ⇒ Montrose::Recurrence
Create a recurrence from the given frequency.
-
#except(date) ⇒ Montrose::Recurrence
Create a recurrence with dates except dates given.
-
#hour_of_day(hours, *extras) ⇒ Montrose::Recurrence
(also: #hour)
Create a recurrence for given hours of day.
-
#hourly(options = {}) ⇒ Montrose::Recurrence
Create a hourly recurrence.
-
#merge(other = {}) ⇒ Montrose::Recurrence
Create a new recurrence combining options of self and other.
-
#minutely(options = {}) ⇒ Montrose::Recurrence
Create a minutely recurrence.
-
#month_of_year(months, *extras) ⇒ Montrose::Recurrence
(also: #month)
Create a recurrence for given months of year.
-
#monthly(options = {}) ⇒ Montrose::Recurrence
Create a monthly recurrence.
-
#on(day) ⇒ Montrose::Recurrence
Create a recurrence through :on option.
-
#starts(starts_at) ⇒ Montrose::Recurrence
(also: #starting)
Create a recurrence starting at given timestamp.
-
#total(total) ⇒ Montrose::Recurrence
(also: #repeat)
Create a recurrence that ends after given number of occurrences.
-
#until(ends_at) ⇒ Montrose::Recurrence
(also: #ending)
Create a recurrence ending at given timestamp.
-
#week_of_year(weeks, *extras) ⇒ Montrose::Recurrence
Create a recurrence for given weeks of year.
-
#weekly(options = {}) ⇒ Montrose::Recurrence
Create a weekly recurrence.
-
#yearly(options = {}) ⇒ Montrose::Recurrence
Create a yearly recurrence.
Instance Method Details
#at(time) ⇒ Montrose::Recurrence
Create a recurrence at given time
228 229 230 |
# File 'lib/montrose/chainable.rb', line 228 def at(time) merge(at: time) end |
#between(date_range) ⇒ Montrose::Recurrence
Create a recurrence occurring between the start and end of a given date range; :between is shorthand for separate :starts and :until options. When used with explicit :start and/or :until options, those will take precedence.
169 170 171 |
# File 'lib/montrose/chainable.rb', line 169 def between(date_range) merge(between: date_range) end |
#branch(options) ⇒ Object
372 373 374 |
# File 'lib/montrose/chainable.rb', line 372 def branch() Montrose::Recurrence.new() end |
#covering(date_range) ⇒ Montrose::Recurrence
Create a recurrence which will only emit values within the date range, also called “masking.”
183 184 185 |
# File 'lib/montrose/chainable.rb', line 183 def covering(date_range) merge(covering: date_range) end |
#daily(options = {}) ⇒ Montrose::Recurrence
Create a daily recurrence.
76 77 78 |
# File 'lib/montrose/chainable.rb', line 76 def daily( = {}) branch .merge(every: :day) end |
#day_of_month(days, *extras) ⇒ Montrose::Recurrence Also known as: mday
Create a recurrence for given days of month
257 258 259 |
# File 'lib/montrose/chainable.rb', line 257 def day_of_month(days, *extras) merge(mday: days.array_concat(extras)) end |
#day_of_week(weekdays, *extras) ⇒ Montrose::Recurrence Also known as: day
Create a recurrence for given days of week
273 274 275 |
# File 'lib/montrose/chainable.rb', line 273 def day_of_week(weekdays, *extras) merge(day: weekdays.array_concat(extras)) end |
#day_of_year(days, *extras) ⇒ Montrose::Recurrence Also known as: yday
Create a recurrence for given days of year
289 290 291 |
# File 'lib/montrose/chainable.rb', line 289 def day_of_year(days, *extras) merge(yday: days.array_concat(extras)) end |
#default_options ⇒ Object
377 378 379 |
# File 'lib/montrose/chainable.rb', line 377 def @default_options ||= Montrose::Options.new end |
#during(time_of_day, *extras) ⇒ Montrose::Recurrence
Create a recurrence occurring within a time-of-day range or ranges. Given time ranges will parse as times-of-day and ignore given dates.
200 201 202 |
# File 'lib/montrose/chainable.rb', line 200 def during(time_of_day, *extras) merge(during: time_of_day.array_concat(extras)) end |
#every(frequency, options = {}) ⇒ Montrose::Recurrence
Create a recurrence from the given frequency
22 23 24 |
# File 'lib/montrose/chainable.rb', line 22 def every(frequency, = {}) branch .merge(every: frequency) end |
#except(date) ⇒ Montrose::Recurrence
Create a recurrence with dates except dates given
242 243 244 |
# File 'lib/montrose/chainable.rb', line 242 def except(date) merge(except: date) end |
#hour_of_day(hours, *extras) ⇒ Montrose::Recurrence Also known as: hour
Create a recurrence for given hours of day
305 306 307 |
# File 'lib/montrose/chainable.rb', line 305 def hour_of_day(hours, *extras) merge(hour: hours.array_concat(extras)) end |
#hourly(options = {}) ⇒ Montrose::Recurrence
Create a hourly recurrence.
58 59 60 |
# File 'lib/montrose/chainable.rb', line 58 def hourly( = {}) branch .merge(every: :hour) end |
#merge(other = {}) ⇒ Montrose::Recurrence
Create a new recurrence combining options of self and other. The value of entries with duplicate keys will be those of other
367 368 369 |
# File 'lib/montrose/chainable.rb', line 367 def merge(other = {}) branch .merge(other) end |
#minutely(options = {}) ⇒ Montrose::Recurrence
Create a minutely recurrence.
40 41 42 |
# File 'lib/montrose/chainable.rb', line 40 def minutely( = {}) branch .merge(every: :minute) end |
#month_of_year(months, *extras) ⇒ Montrose::Recurrence Also known as: month
Create a recurrence for given months of year
321 322 323 |
# File 'lib/montrose/chainable.rb', line 321 def month_of_year(months, *extras) merge(month: months.array_concat(extras)) end |
#monthly(options = {}) ⇒ Montrose::Recurrence
Create a monthly recurrence.
108 109 110 |
# File 'lib/montrose/chainable.rb', line 108 def monthly( = {}) branch .merge(every: :month) end |
#on(day) ⇒ Montrose::Recurrence
Create a recurrence through :on option
214 215 216 |
# File 'lib/montrose/chainable.rb', line 214 def on(day) merge(on: day) end |
#starts(starts_at) ⇒ Montrose::Recurrence Also known as: starting
Create a recurrence starting at given timestamp.
138 139 140 |
# File 'lib/montrose/chainable.rb', line 138 def starts(starts_at) merge(starts: starts_at) end |
#total(total) ⇒ Montrose::Recurrence Also known as: repeat
Create a recurrence that ends after given number of occurrences
351 352 353 |
# File 'lib/montrose/chainable.rb', line 351 def total(total) merge(total: total) end |
#until(ends_at) ⇒ Montrose::Recurrence Also known as: ending
Create a recurrence ending at given timestamp.
152 153 154 |
# File 'lib/montrose/chainable.rb', line 152 def until(ends_at) merge(until: ends_at) end |
#week_of_year(weeks, *extras) ⇒ Montrose::Recurrence
Create a recurrence for given weeks of year
337 338 339 |
# File 'lib/montrose/chainable.rb', line 337 def week_of_year(weeks, *extras) merge(week: weeks.array_concat(extras)) end |
#weekly(options = {}) ⇒ Montrose::Recurrence
Create a weekly recurrence.
93 94 95 |
# File 'lib/montrose/chainable.rb', line 93 def weekly( = {}) branch .merge(every: :week) end |
#yearly(options = {}) ⇒ Montrose::Recurrence
Create a yearly recurrence.
125 126 127 |
# File 'lib/montrose/chainable.rb', line 125 def yearly( = {}) branch .merge(every: :year) end |