Class: LWAC::JSONFormatter
- Inherits:
-
KeyValueFormatter
- Object
- Formatter
- KeyValueFormatter
- LWAC::JSONFormatter
- Defined in:
- lib/lwac/export/format.rb
Overview
Output to a single JSON file
Instance Method Summary collapse
- #close_output ⇒ Object
- #close_point ⇒ Object
-
#open_output ⇒ Object
TODO: - sync after every write - use formatter system].
- #write_header ⇒ Object
Methods inherited from KeyValueFormatter
#add_data, #initialize, #open_point
Methods inherited from Formatter
#<<, #add_data, #initialize, #open_point
Constructor Details
This class inherits a constructor from LWAC::KeyValueFormatter
Instance Method Details
#close_output ⇒ Object
96 97 98 99 |
# File 'lib/lwac/export/format.rb', line 96 def close_output() $log.info "Closing output CSV..." @f.close end |
#close_point ⇒ Object
107 108 109 110 111 112 |
# File 'lib/lwac/export/format.rb', line 107 def close_point() super @f.write(JSON.generate(@line.values)) @f.write("\n") @f.flush end |
#open_output ⇒ Object
TODO: - sync after every write
- use formatter system]
91 92 93 94 |
# File 'lib/lwac/export/format.rb', line 91 def open_output() $log.info "Opening #{@config[:filename]} for writing..." @f = File.open( @config[:filename], 'w' ) end |
#write_header ⇒ Object
101 102 103 104 105 |
# File 'lib/lwac/export/format.rb', line 101 def write_header $log.info "Writing header" @f.write( @config[:fields].keys ) @f.flush end |