ruby遍历文件夹

def get_file_list(path)  
  Dir.entries(path).each do |sub|         
    if sub != '.' && sub != '..'  
      if File.directory?("#{path}/#{sub}")  
        puts "[#{sub}]"  
        get_file_list("#{path}/#{sub}")  
      else  
        puts "  |--#{sub}"  
      end  
    end  
  end  
end 

原文地址:https://www.cnblogs.com/zhangfei/p/2708668.html