Class: Jrf::InputReader::RsNormalizer
- Inherits:
-
Object
- Object
- Jrf::InputReader::RsNormalizer
- Defined in:
- lib/jrf/input_reader.rb
Overview
Translates JSON-SEQ record separators (RS, 0x1e) to newlines so the underlying Oj scanner sees a stream of whitespace-delimited values.
Instance Method Summary collapse
-
#initialize(input) ⇒ RsNormalizer
constructor
A new instance of RsNormalizer.
- #read(length = nil, outbuf = nil) ⇒ Object
Constructor Details
#initialize(input) ⇒ RsNormalizer
Returns a new instance of RsNormalizer.
63 64 65 |
# File 'lib/jrf/input_reader.rb', line 63 def initialize(input) @input = input end |
Instance Method Details
#read(length = nil, outbuf = nil) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/jrf/input_reader.rb', line 67 def read(length = nil, outbuf = nil) chunk = @input.read(length) return nil if chunk.nil? chunk.tr!(RS_CHAR, "\n") if outbuf outbuf.replace(chunk) else chunk end end |