Class: Wukong::Processor::FromTsv

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

Overview

A widget for deserializing inputs from TSV.

Examples:

Deserializing from TSV at the beginning of a data flow


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

Yields the input record deserialized from TSV.

Parameters:

Yields:

  • (obj)

    the deserialized object

Yield Parameters:

  • obj (Object)


139
140
141
142
143
144
145
146
147
148
# File 'lib/wukong/widget/serializers.rb', line 139

def process(record)
  if record.respond_to?(:from_tsv)
    obj = record.from_tsv
  else
    obj = record.split(/\t/)
  end
  yield obj
rescue => e        
  handle_error(record, e)
end