Date_Range.with_step
with_stepnew_step
Group: Calculations
Documentation
Creates a copy of this range with a changed step.
Arguments
new_step: The new step to use. It can either be aDate_PeriodorPeriod. The providedPeriodmust be positive, i.e. all ofyears,monthsanddaysmust be non-negative and at least one of them has to be positive.
Examples
Create a range representing the first day of every month in a year.
(Date.new 2020 1 1).up_to (Date.new 2020 12 31) . with_step Date_Period.Month
Create a a decreasing range of every other day between two dates.
(Date.new 2022 10 23).down_to (Date.new 2022 10 1) . with_step (Period.new days=2)