switch to strings

This commit is contained in:
John Bintz 2010-01-04 19:44:39 -05:00
parent b0de0b1d98
commit e99e08f3e7
2 changed files with 14 additions and 14 deletions

View File

@ -22,7 +22,7 @@ class Scheduler
def ok_to_add(date, breaks)
ok = true
breaks.each do |i|
if (i[:from] <= date) && (i[:to] >= date)
if (i['from'] <= date) && (i['to'] >= date)
ok = false
end
end
@ -32,13 +32,13 @@ class Scheduler
def schedule(parameters, to_produce)
dates = []
if parameters[:start]
current = parameters[:start]
if parameters['start']
current = parameters['start']
breaks = parameters[:breaks] || []
breaks = parameters['breaks'] || []
while dates.length < to_produce
interval = parameters[:interval].shift
interval = parameters['interval'].shift
case interval.class.to_s
when 'String'
@ -57,7 +57,7 @@ class Scheduler
current += interval
end
parameters[:interval] << interval
parameters['interval'] << interval
end
end

View File

@ -13,26 +13,26 @@ class TestScheduler < Test::Unit::TestCase
[
[
{
:start => DateTime.parse('2010-01-01'),
:interval => Scheduler::WEEKLY
'start' => DateTime.parse('2010-01-01'),
'interval' => Scheduler::WEEKLY
},
2,
[ DateTime.parse('2010-01-01'), DateTime.parse('2010-01-08') ]
],
[
{
:start => DateTime.parse('2010-01-01'),
:interval => [ 'monday' ]
'start' => DateTime.parse('2010-01-01'),
'interval' => [ 'monday' ]
},
2,
[ DateTime.parse('2010-01-04'), DateTime.parse('2010-01-11') ]
],
[
{
:start => DateTime.parse('2010-01-01'),
:interval => Scheduler::DAILY,
:breaks => [
{ :from => DateTime.parse('2010-01-03'), :to => DateTime.parse('2010-01-05') }
'start' => DateTime.parse('2010-01-01'),
'interval' => Scheduler::DAILY,
'breaks' => [
{ 'from' => DateTime.parse('2010-01-03'), 'to' => DateTime.parse('2010-01-05') }
]
},
4,