Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- file_path = __dir__ + '/data/1.txt'
- abort 'Файл не найден' unless File.exist?(file_path)
- lines = File.readlines(file_path, encoding: 'UTF-8')
- puts "Всего строк: #{lines.size}"
- empty_count = lines.count { |line| line == "\n" }
- puts "Пустых строк: #{empty_count}"
- puts "Последние 5 строк: "
- puts
- lines[-5..-1].each do |line|
- puts line
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement