Class: I18n::Tasks::Scanners::Files::FileReader

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n/tasks/scanners/files/file_reader.rb

Overview

Reads the files in ‘rb’ mode and UTF-8 encoding.

Since:

  • 0.9.0

Direct Known Subclasses

CachingFileReader

Instance Method Summary collapse

Instance Method Details

#read_file(path) ⇒ String

Return the contents of the file at the given path. The file is read in the ‘rb’ mode and UTF-8 encoding.

Parameters:

  • path (String)

    Path to the file, absolute or relative to the working directory.

Returns:

  • (String)

    file contents

Since:

  • 0.9.0



13
14
15
16
17
# File 'lib/i18n/tasks/scanners/files/file_reader.rb', line 13

def read_file(path)
  result = nil
  File.open(path, 'rb', encoding: 'UTF-8') { |f| result = f.read }
  result
end