Created
September 2, 2016 00:42
-
-
Save dugancathal/81a7a41af1643174bcb6346b22ef1733 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'csv' | |
ORDERING_FREQUENCY = ['Monday', 'Thursday', 'Wednesday'] | |
def date_of_next(day, anchor) | |
anchor + 0.upto(6).find {|i| Date::DAYNAMES[(anchor + i).wday] == day } | |
end | |
people = CSV.parse(File.read(ARGV[0])).shuffle | |
start = Date.parse(ARGV[1]) rescue Date.today | |
schedule = ORDERING_FREQUENCY.cycle.take(30).map {|day| start = date_of_next(day, start) } | |
puts schedule.each_with_object(Array.new).with_index {|(date, arr), i| | |
arr << [date.to_s, people[i % people.length]].join(',') | |
}.join("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment