In my opinion, it depends on the complexity of the lines being explained. In this concrete case, I like how I can read through the code like this:

1. Remove all double slashes
1. Remove every URL segment that consists solely of dots
1. Append a trailing slash to the URL if the unsanitized URL had one

It is, again in my opinion, way nicer than having to read this:

1. `url = in_url.gsub(/\/\//, "/")`
1. `url = url.split('/').reject{ |part| part =~ /^\.+$/ }.join('/')`
1. `url += "/" if in_url =~ /\/$/`