```Here is my solution. It took me a few tries to find an elegant
solution for the to_s function, but i particularly like this one :)

require 'facets/core/enumerable/map_with_index'
class DayRange
DAY_NAMES = {'Monday'=>1,'Tuesday'=>2,'Wednesday'=>3,'Thursday'=>4,'Friday'=>5,'Saturday'=>6,'Sunday'=>7}
DAY_ABBR  = {'Mon'=>1   ,'Tue'=>2    ,'Wed'=>3      ,'Thu'=>4
,'Fri'=>5   ,'Sat'=>6     ,'Sun'=>7   }
def initialize(*days)
@days = days.map{|d| DAY_NAMES[d] || DAY_ABBR[d] || d.to_i }.uniq.sort
raise ArgumentError, 'Invalid day' unless @days.all?{|d| (1..7).include? d }
end

def to_s
@days.map_with_index{|d,ix| DAY_ABBR.invert[d] unless
@days[ix+1]==@days[ix-1]+2 }.join(', ').gsub(/(, ){2,}/,'-')
end
end

if __FILE__==\$0

require 'test/unit'
class DayRangeTests < Test::Unit::TestCase
def test_init
assert_raise(ArgumentError) { DayRange.new(1,2,3,5,8) }
assert_raise(ArgumentError) { DayRange.new(1,'Mon','foo') }
assert_nothing_raised {
DayRange.new()
DayRange.new(1,1,2,'Wed','Monday','Fri','Tue',3,4,'Friday',5)
}
end

def test_to_s
assert_equal 'Mon', DayRange.new('Mon').to_s
assert_equal 'Mon-Wed', DayRange.new(1,1,2,'Wed').to_s
assert_equal 'Mon-Sun', DayRange.new(*1..7).to_s
assert_equal 'Mon-Wed, Fri-Sun',
DayRange.new('Monday',2,3,'Sunday',6,6,5).to_s
assert_equal 'Mon, Wed, Fri, Sun',
DayRange.new('Mon','Sun','Wed','Sunday',7,5).to_s
end
end

end

```