draft solution -- for review only -- do not merge!

@haf while this is not valid Ruby (which I do not master), this will hopefully allow you to get the ideas of the proposed solution. Your comments are appreciated. 
Same on Windows.