# DayRange(#92) - My solution

**URL:** <https://www.ruby-forum.com/t/dayrange-92-my-solution/66994>\
**Category:** Ruby\
**Created:** [August 30, 2006, 8:25pm UTC](https://www.ruby-forum.com/t/dayrange-92-my-solution/66994 "2006-08-30T20:25:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rykkers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e5b9ba/32.png) [@rykkers](https://www.ruby-forum.com/u/rykkers)\
**Post date:** [August 30, 2006, 8:25pm UTC](https://www.ruby-forum.com/t/dayrange-92-my-solution/66994/1 "2006-08-30T20:25:56Z")

</div>

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.

1. Rails style options can be used on new, to\_s and a few more.
2. 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’ .
3. Option to select a language. English and French are built-in.
4. 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.
5. 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’ 
6. Probably some other things I’m overlooking as I type this note.

–  
Rick DeNatale

My blog on Ruby  
[http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)
