Class: Wukong::Processor::ToCsv

Inherits:
Serializer show all
Defined in:
lib/wukong/widget/serializers.rb

Overview

A widget for serializing inputs to CSV.

Examples:

Serializing to CSV at the end of a data flow


Wukong.dataflow(:emits_csv) do
  ... | to_csv
end

See Also:

Constant Summary

Constants inherited from Wukong::Processor

SerializerError

Instance Method Summary collapse

Methods inherited from Serializer

#handle_error

Methods inherited from Wukong::Processor

configure, consumes, description, #expected_record_type, #expected_serialization, #finalize, #perform_action, produces, #receive_action, #setup, #stop, valid_serializer?, validate_and_set_serialization

Methods included from Logging

included

Methods included from Hanuman::StageClassMethods

#builder, #label, #register, #set_builder

Instance Method Details

#process(record) {|csv| ... } ⇒ Object

Yields the input record serialized as CSV.

Parameters:

  • record (Object)

Yields:

  • (csv)

    the serialized CSV output

Yield Parameters:



167
168
169
170
171
172
173
174
175
# File 'lib/wukong/widget/serializers.rb', line 167

def process(record)
  begin
    csv = record.map(&:to_s).join(",")
  rescue => e
    # FIXME -- should we log here or what?
    return
  end
  yield csv
end