Class: Wukong::Processor::ToDelimited

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

Overview

A widget for serializing inputs to a delimited format.

Examples:

Serializing to a delimited format at the end of a data flow


Wukong.dataflow(:emits_delimited) do
  ... | to_delimited(delimiter: "--")
end

See Also:

Constant Summary

Constants inherited from Wukong::Processor

SerializerError

Instance Attribute Summary

Attributes included from Hanuman::StageInstanceMethods

#graph

Instance Method Summary collapse

Methods inherited from Serializer

#handle_error

Methods inherited from Wukong::Processor

configure, description, #finalize, #perform_action, #receive_action, #setup, #stop

Methods included from Logging

included

Methods inherited from Hanuman::Stage

#clone

Methods included from Hanuman::StageClassMethods

#builder, #label, #register, #set_builder

Methods included from Hanuman::StageInstanceMethods

#add_link, #linkable_name, #root

Instance Method Details

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

Yields the input record serialized in a delimited format..

Parameters:

  • record (Object)

Yields:

  • (delimited)

    the serialized delimited output

Yield Parameters:



220
221
222
223
224
225
226
227
228
# File 'lib/wukong/widget/serializers.rb', line 220

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