Partendo dalla risposta di Chandra, a seconda se è necessario o meno il percorso completo, è possibile utilizzare
Dir['app/*/']
# => ["app/controllers/", "app/helpers/", "app/metal/", "app/models/", "app/sweepers/", "app/views/"
Dir['app/*/'].map { |a| File.basename(a) }
# => ["controllers", "helpers", "metal", "models", "sweepers", "views"]
Se usi Ruby> = 1.8.7, la risposta di Chandra può anche essere riscritta come
Pathname.glob('app/*/').map(&:basename)
# you can skip .to_s unless you don't need to work with strings
# remember you can always use a pathname as string for the most part of Ruby functions
# or interpolate the value
fonte
2010-01-06 13:01:34
possibile duplicato di [Ottenere un elenco di cartelle in una directory] (http://stackoverflow.com/questions/1899072/getting-a-list-of-folders-in-a-directory) –