Class: Ppson::FileJsonReader

Inherits:
Object
  • Object
show all
Defined in:
lib/ppjson/file_json_reader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filepath) ⇒ FileJsonReader

Returns a new instance of FileJsonReader.



5
6
7
# File 'lib/ppjson/file_json_reader.rb', line 5

def initialize(filepath)
  @filepath = filepath
end

Instance Attribute Details

#filepathObject (readonly)

Returns the value of attribute filepath.



3
4
5
# File 'lib/ppjson/file_json_reader.rb', line 3

def filepath
  @filepath
end

Instance Method Details

#readObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ppjson/file_json_reader.rb', line 9

def read
  contents = nil
  begin
    File.open(filepath, 'r') do |file|
      contents = file.readlines.join("")
    end
  rescue => e
    Escort::Logger.error.warn("Error reading file #{filepath}")
  end
  contents
end