[TIL Tips] Iterate between Date objects in ruby
tl;dr:
Using the standard ruby range
:
(Date.new(2018, 01, 01)..Date.new(2018, 01, 30)).each do |date|
# Do stuff with date
end
Using the Date
method upto
:
Date.new(2018, 01, 01).upto(Date.new(2018, 01, 30)) do |date|
# Do stuff with date
end