SHARE
TWEET

Untitled

a guest Jun 20th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. file_path = __dir__ + '/data/1.txt'
  2.  
  3. abort 'Файл не найден' unless File.exist?(file_path)
  4.  
  5. lines = File.readlines(file_path, encoding: 'UTF-8')
  6. puts "Всего строк: #{lines.size}"
  7.  
  8. empty_count = lines.count { |line| line == "\n" }
  9. puts "Пустых строк: #{empty_count}"
  10.  
  11. puts "Последние 5 строк: "
  12. puts
  13. lines[-5..-1].each do |line|
  14.   puts line
  15. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top