Class: Ppson::FileJsonReader
- Inherits:
-
Object
- Object
- Ppson::FileJsonReader
- Defined in:
- lib/ppjson/file_json_reader.rb
Instance Attribute Summary collapse
-
#filepath ⇒ Object
readonly
Returns the value of attribute filepath.
Instance Method Summary collapse
-
#initialize(filepath) ⇒ FileJsonReader
constructor
A new instance of FileJsonReader.
- #read ⇒ Object
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
#filepath ⇒ Object (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
#read ⇒ Object
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 |