Class: Tb::NDJSONReader
- Inherits:
-
HashReader
- Object
- HashReader
- Tb::NDJSONReader
- Defined in:
- lib/tb/ndjson.rb
Instance Method Summary collapse
-
#initialize(io) ⇒ NDJSONReader
constructor
io.gets should returns a string.
Methods inherited from HashReader
#get_hash, #get_named_header, #header_and_each, #header_known?, #update_header
Methods included from EnumerableWithEach
Methods included from Enumerable
#cat, #extsort_by, #natjoin2, #natjoin2_outer, #newfield, #to_fileenumerator, #with_cumulative_header, #with_header, #write_to_csv, #write_to_json, #write_to_ltsv, #write_to_pnm, #write_to_tsv, #write_with
Constructor Details
#initialize(io) ⇒ NDJSONReader
io.gets should returns a string.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/tb/ndjson.rb', line 39 def initialize(io) super lambda { while true line = io.gets if line.nil? || /\S/ =~ line break end end if line JSON.parse(line) else nil end } end |