Class: Dap::Input::InputJSON
- Inherits:
-
Object
- Object
- Dap::Input::InputJSON
- Includes:
- FileSource
- Defined in:
- lib/dap/input.rb
Overview
JSON Input (line-delimited records)
Instance Attribute Summary
Attributes included from FileSource
Instance Method Summary collapse
-
#initialize(args) ⇒ InputJSON
constructor
A new instance of InputJSON.
- #read_record ⇒ Object
Methods included from FileSource
Constructor Details
#initialize(args) ⇒ InputJSON
Returns a new instance of InputJSON.
57 58 59 |
# File 'lib/dap/input.rb', line 57 def initialize(args) self.open(args.first) end |
Instance Method Details
#read_record ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/dap/input.rb', line 61 def read_record line = self.fd.readline rescue nil return Error::EOF unless line begin json = Oj.load(line.strip, mode: :strict) rescue $stderr.puts "Record is not valid JSON and will be skipped: '#{line}'" return Error::InvalidFormat end return Error::Empty unless json json end |