Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Date#step

d.step(limit[, step=1]) → enumerator
d.step(limit[, step=1]){|date| ...} → self

Iterates evaluation of the given block, which takes a date object. The limit should be a date object.

Example
Date.new(2001).step(Date.new(2001,-1,-1)).select{|d| d.sunday?}.size
                          #=> 52
See also #start #strftime #second #succ also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1