making ex20 more ruby-ish

This commit is contained in:
Dan Buch 2012-03-21 22:04:36 -04:00
parent a9ac349ba9
commit aa308911d4

10
ex20.rb
View File

@ -1,7 +1,7 @@
input_file = ARGV[0]
input_file = ARGV.first
def print_all(f)
puts f.read()
puts f.read
end
def rewind(f)
@ -9,7 +9,7 @@ def rewind(f)
end
def print_a_line(line_count, f)
puts "#{line_count} #{f.readline()}"
puts "#{line_count} #{f.readline}"
end
current_file = File.open(input_file)
@ -28,8 +28,8 @@ puts "Let's print three lines:"
current_line = 1
print_a_line(current_line, current_file)
current_line = current_line + 1
current_line += 1
print_a_line(current_line, current_file)
current_line = current_line + 1
current_line += 1
print_a_line(current_line, current_file)