Guest User

Untitled

a guest
Jul 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. def self.cleanpath(orig_path)
  2. nodes = Pathname.new(orig_path).cleanpath.to_s.split('/')
  3.  
  4. realnames = ['.']
  5.  
  6. nodes.each do |node|
  7. path = realnames.join('/')
  8.  
  9. entries = Dir.entries(path).select { |entry| entry.downcase == node.downcase }
  10.  
  11. realnames << if entries.size == 1
  12. entries.first
  13. else
  14. node
  15. end
  16. end
  17.  
  18. realnames.join('/')
  19. end
Add Comment
Please, Sign In to add comment