From: Yossef Mendelssohn Date: 2007-10-25T11:25:37+09:00 Subject: Re: Time Window (#144) On Oct 24, 9:16 am, James Edward Gray II wrote: > On Oct 24, 2007, at 9:10 AM, Ken Bloom wrote: > > > > > On Wed, 24 Oct 2007 10:04:56 +0900, James Koppel wrote: > > >> Here's my solution. It converts atimewindowinto an array of > >> arrays of > >> ranges. Each range matches an interval oftime(e.g.: 500..1700); > >> each > >> subarray contains all the ranges for a given day. I then wrote the > >> simple Array#some method that returns true if the given predicate > >> returns true for at least one of its elements, which I used to write > >> TimeWindow#incude?. > > >> $days = {"Sun"=>0, > >> "Mon"=>1, > >> "Tue"=>2, > >> "Wed"=>3, > >> "Thu"=>4, > >> "Fri"=>5, > >> "Sat"=>6} > > > I suggest using a constant rather than a global variable for this. You > > can put the constant in the TimeWindow class. > > This is also just an Array disguised as a Hash. > > James Edward Gray II It could be a lot worse. Which of us hasn't run across something like this? days = { 0 => 'Sun', 1 => 'Mon', 2 => 'Tue', 3 => 'Wed', 4 => 'Thu', 5 => 'Fri', 6 => 'Sat', } -- -yossef