-- -ello quizzers,
My solution ended up being something of an ode to the Enumerable#inject method
(so elegant!), and a chance to implement the flyweight design pattern (for the
Day class). I also named my class 'DaySet', which seemed more accurate to me
than 'DayRange', and hopefully won't invalidate my solution ;-).
The appended test suite made the file a touch long, so I've included it as an
attachment.
-Marshall
-- -Content-Type: text/x-ruby
Content-Disposition: inline; filename=day_set.rb
Content-Description: Ruby Quiz #92 Solution
#! /usr/bin/env ruby
require 'enumerator'
require 'facet/symbol/to_proc'
class DaySet
class Day
include Comparable
# Convenience conversion routines
class ::String; def to_day; Day.new(self); end; end
class ::Integer; def to_day; Day.new(self); end; end
# Hash providing basic day name <