Ruby: Line based file access
Mittwoch, 20. April 2011, 07:18 Uhr | roberto@vasquez-angel.de |Counting lines
I did find some fancy examples, but I wanted to have it look nice, so I came up with this:
File.new('some_file.txt', "r").lines.count
Access a specific line
File.open('some_file.txt', "r") do |file| nth_line_content = file.lines.entries[n] end