I sent this before with a big zipfile attachment including rdoc, and I
think that the mailing list rejected it due to the size of the
attachment. So I’m sending it again with just the source files.
After solving the basic problem in a few minutes, doing the “simplest
thing which could possibly work,” I’ve spent my spare time over the
last 4 or 5 days letting features, well, creep.
I’ve noticed that there are two major styles of quiz respondants, some
go for brief code, others go for well-documented code sometimes with
lots of new features. I guess I fall into the latter camp.
I really used this as an exercise to explore implementing rails-like
options parameters. The code is documented, and I’ve included the
html output of rdoc in the attached zip file. There’s also a test
script.
So here’s my solution. A few goodies I’ve added.
- Rails style options can be used on new, to_s and a few more.
- Option to select when the week starts, the ranges produced in to_s
will never span over a week boundary.
I just realized that I really should let you specify the start of the
week as either a number or a name, but it’s time to lay my cards on
the table, so names will have to wait until the next ‘release’ . - Option to select a language. English and French are built-in.
- Support for ad-hoc languages, and adding new languages via a class
method, see the rdoc and testcases for examples of how to do this. - A DayRange is enumerable and should act like an array containing
the day numbers with the week-start fixed as Monday=1, extension to
add options are on the ‘roadmap’ - Probably some other things I’m overlooking as I type this note.
–
Rick DeNatale
My blog on Ruby
http://talklikeaduck.denhaven2.com/