Advertisement
abinoam

answer for cynic limb at ruby talk

Jan 28th, 2014
121
0
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. #!/usr/bin/env ruby
  6.  
  7. print "File name: "
  8. filename = gets.chomp
  9.  
  10. unless File.file? filename
  11.   puts "The given name '#{filename} is not a file"
  12.   exit
  13. end
  14.  
  15. unless File.readable? filename
  16.   puts "The given file '#{filename}' is not readable."
  17.   exit
  18. end
  19.  
  20. File.open filename, 'r' do |f|
  21.   f.each_line do |line|
  22.     puts line
  23.   end
  24. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement