Module: Readlines::File

Included in:
ReadDuc
Defined in:
lib/readlines/readlines/file.rb

Instance Method Summary collapse

Instance Method Details

#file_statistics_nowObject

Raises:

  • (Readlines::NotFoundError)


8
9
10
11
12
13
14
15
16
17
# File 'lib/readlines/readlines/file.rb', line 8

def file_statistics_now
    raise Readlines::NotFoundError, "File not found: #{@file_path}" unless ::File.exist?(@file_path)

    content = ::File.read(@file_path)
    {
      lines: content.lines.count,
      characters: content.length,
      words: content.split.length
    }
end