Class: Wukong::Processor::FromCsv

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

Overview

A widget for deserializing inputs from CSV.

Examples:

Deserializing from CSV at the beginning of a data flow


Wukong.dataflow(:consumes_csv) do
  from_csv | ...
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(csv) {|obj| ... } ⇒ Object

Yields the input record deserialized from CSV.

Parameters:

Yields:

  • (obj)

    the deserialized object

Yield Parameters:

  • obj (Object)


192
193
194
195
196
197
198
199
200
# File 'lib/wukong/widget/serializers.rb', line 192

def process(csv)
  begin
    record = csv.split(/,/)
  rescue => e
    # FIXME -- should we log here or what?
    return
  end
  yield record
end