file

Ruby: getting a list of all files in a directory

basedir = "."
contains = Dir.new(basedir).entries
 
puts contains

Source:
http://www.wellho.net/resources/ex.php4?item=r106/afid.rb

Checking to see if a directory exists in ruby

This was the winning code:

path="/some/path"
if File.exists?(path) && File.directory?(path)
    puts "yeeha"
else
    puts "bummer"
end

from this source http://www.ruby-forum.com/topic/135748

Syndicate content