I am currently doing this:
x = Date.today
y = x + 12.weeks
(x..y).each do |date|
next unless date.strftime("%A") == 'Friday'
@dates << date
end
There has to be better code to do this, can anyone give it to me or give me the right thing to开发者_开发技巧 look for to find how to do it?
Thanks
Nice one-liner: (Date.today..Date.today + 12.weeks).select(&:friday?)
- Voila!
x = Date.today
x += 1.day while x.wday < 5
@dates = (0...12).map{|i| x+i.weeks}
精彩评论