Creating a weekly-planner template in a text file

The following script generates a simple weeky planner template, starting from today:

require 'date'

d = DateTime.now

def ordinal(n)
  n.to_s + ( (10...20).include?(n) ? 'th' : \
                  %w{ th st nd rd th th th th th th }[n % 10] )
end

a = []
a <<  "%s, %s %s" % [Date::DAYNAMES[d.wday], ordinal(d.day), Date::ABBR_MONTHNAMES[d.month]]
a += (d+1).upto(d+6).map do |date| 
  Date::ABBR_DAYNAMES[date.wday]
end

a2 = a.map {|x| "%s\n%s" % [x, '-' * x.length]}
s = "weekly-planner.txt\n==================\n\n%s\n\n" % [a2.join("\n\n")]
File.write 'weekly-planner.txt', s

Output

weekly-planner.txt
==================

Sunday, 6th Dec
---------------

Mon
---

Tue
---

Wed
---

Thu
---

Fri
---

Sat
---