Return to Snippet

Revision: 20314
at November 11, 2009 22:04 by chrisaiv


Initial Code
puts File.dirname(__FILE__)

#Keeps track of where you are at this moment, it might change often
puts Dir.pwd
#Change Directory
#puts Dir.chdir( File.join('', '') )
#An array of info within the directories
puts Dir.entries('.')
#Code block of files within a directory
Dir.entries('.').each do |entry|
  print entry + ": "
  if File.file?(entry) && File.readable?(entry)
    File.open(entry, 'r') do |file|
      puts file.gets
    end
  else
    puts
  end
end

Dir.foreach("."){ |entry| puts entry }

Dir.mkdir('temp_directory')
Dir.delete('temp_directory')

Initial URL


Initial Description


Initial Title
Ruby: Directory Class Methods

Initial Tags
file, ruby

Initial Language
Ruby