#!/usr/bin/ruby

class Horaire
	def initialize()
		@@tab = Array.new
		while ligne = gets
			ligne = ligne.chomp
			sp = ligne.split(/\t/)
			if sp.length>2
				@@tab << sp
			end
		end
	end
	
	def to_s
		@@tab.each do |ligne|
			ligne.each do |elt|
				print "#{elt}\t"
			end
			print "\n"
		end
	end
	
	def plotdata
		maxLen = 0
		@@tab.each do |ligne|
			if ligne.length > maxLen
				maxLen = ligne.length
			end
		end
		
		mission = 1
		
		for j in 2...maxLen
			print "# Mission ", mission, "\n"
			mission += 1
			for i in 0...@@tab.length
				if @@tab[i][j] && @@tab[i][j] != ""
					print @@tab[i][1], "\t", @@tab[i][j], "\n"
				end
			end
			print "\n\n"
		end
	end
end

horaire = Horaire.new
horaire.plotdata

