Skip to content

Instantly share code, notes, and snippets.

@superfeedr
Created August 17, 2010 13:07
Show Gist options
  • Save superfeedr/529849 to your computer and use it in GitHub Desktop.
Save superfeedr/529849 to your computer and use it in GitHub Desktop.
class File
def self.canonical(_path)
_path.split("/").inject([]) { |p,n|
case n
when "."
p
when ".."
p.pop
p
else
p.push(n)
p
end
}.join "/"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment