Class: LWAC::KeyValueFormatter
- Defined in:
- lib/lwac/export/format.rb
Overview
Formatters that support key-value pairs as selected by a ‘fields’ config item
Direct Known Subclasses
Instance Method Summary collapse
- #add_data(data) ⇒ Object
-
#initialize(config = {}) ⇒ KeyValueFormatter
constructor
A new instance of KeyValueFormatter.
- #open_point ⇒ Object
Methods inherited from Formatter
#<<, #close_output, #close_point, #open_output, #write_header
Constructor Details
#initialize(config = {}) ⇒ KeyValueFormatter
Returns a new instance of KeyValueFormatter.
60 61 62 63 64 |
# File 'lib/lwac/export/format.rb', line 60 def initialize(config = {}) super(config) raise "No fields in field listing" if (not (@config[:fields] and @config[:fields].length > 0) ) KeyValueFormat::compile_format_procedures( @config[:fields] ) end |
Instance Method Details
#add_data(data) ⇒ Object
73 74 75 76 77 |
# File 'lib/lwac/export/format.rb', line 73 def add_data(data) $log.debug "KV: Adding data: #{data}" @data = data @line.merge! KeyValueFormat::produce_output_line( data, @config[:fields] ) end |
#open_point ⇒ Object
67 68 69 70 71 |
# File 'lib/lwac/export/format.rb', line 67 def open_point() $log.debug "KV: Opening new point" @data = nil @line = {} end |