SHOW:
|
|
- or go back to the newest paste.
| 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 | - | if File.readable?("#{filename}")
|
| 8 | + | |
| 9 | ||
| 10 | - | File.open("#{filename}", "r") do |f|
|
| 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 | - | else puts "The given file '#{filename}' is not readable."
|
| 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 |