Advertisement
Guest User

File.readable? How To Make It Work?

a guest
Jan 28th, 2014
123
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. =begin
  2. The following block of code belongs to a program that is under construction currently
  3. =end
  4.  
  5. print "File name: "
  6. filename = gets.chomp
  7.  
  8. if File.readable?("#{filename}")
  9.  
  10. File.open("#{filename}", "r") do |f|
  11.   f.each_line do |line|
  12.     puts line
  13.   end
  14. end
  15.  
  16. else puts "The given file '#{filename}' is not readable."
  17. end
Advertisement
RAW Paste Data Copied
Advertisement