Skip to content

Instantly share code, notes, and snippets.

@caged caged/coaches.rb
Last active May 7, 2016

What would you like to do?
#!/usr/bin/env ruby
require 'csv''coaches2.csv')[1..-1]
stints = coach_years.sort_by(&:reverse).each_with_object([]) do |coach_year, coach_stints|
season, coach = coach_year
start_year = season.split('-')[0].to_i
end_year = start_year + 1
last_stint = coach_stints.last
if [coach, start_year] == last_stint&.fetch_values(:coach, :end_year)
last_stint[:end_year] = end_year
coach_stints << { coach: coach, start_year: start_year, end_year: end_year }
stints.sort_by!{|s| [s[:start_year], s[:end_year]]}
puts stints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.