Skip to content

Instantly share code, notes, and snippets.

@dugancathal
Created September 2, 2016 00:42
Show Gist options
  • Save dugancathal/81a7a41af1643174bcb6346b22ef1733 to your computer and use it in GitHub Desktop.
Save dugancathal/81a7a41af1643174bcb6346b22ef1733 to your computer and use it in GitHub Desktop.
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