IMHO `tpath += '/' if not tpath.end_with?('/')`would be more readable.