Class: Dap::Input::InputJSON

Inherits:
Object
  • Object
show all
Includes:
FileSource
Defined in:
lib/dap/input.rb

Overview

JSON Input (line-delimited records)

Instance Attribute Summary

Attributes included from FileSource

#fd

Instance Method Summary collapse

Methods included from FileSource

#close, #open

Constructor Details

#initialize(args) ⇒ InputJSON

Returns a new instance of InputJSON.



56
57
58
# File 'lib/dap/input.rb', line 56

def initialize(args)
  self.open(args.first)
end

Instance Method Details

#read_recordObject



60
61
62
63
64
65
66
# File 'lib/dap/input.rb', line 60

def read_record  
  line = self.fd.readline rescue nil
  return Error::EOF unless line
  json = Oj.load(line.strip) rescue nil
  return Error::Empty unless json
  json
end