From e99e08f3e77cdab8dfbb21d6a049020de74fc85f Mon Sep 17 00:00:00 2001 From: John Bintz Date: Mon, 4 Jan 2010 19:44:39 -0500 Subject: [PATCH] switch to strings --- classes/Scheduler.rb | 12 ++++++------ tests/TestScheduler.rb | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/classes/Scheduler.rb b/classes/Scheduler.rb index 71e84d7..6ab6365 100644 --- a/classes/Scheduler.rb +++ b/classes/Scheduler.rb @@ -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 diff --git a/tests/TestScheduler.rb b/tests/TestScheduler.rb index 0e68f6b..abfed5c 100644 --- a/tests/TestScheduler.rb +++ b/tests/TestScheduler.rb @@ -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,