Class: Wukong::Processor::ToTsv
- Inherits:
-
Serializer
- Object
- Hanuman::Stage
- Wukong::Processor
- Serializer
- Wukong::Processor::ToTsv
- Defined in:
- lib/wukong/widget/serializers.rb
Overview
A widget for serializing inputs to TSV.
Constant Summary
Constants inherited from Wukong::Processor
Instance Attribute Summary
Attributes included from Hanuman::StageInstanceMethods
Instance Method Summary collapse
-
#process(record) {|tsv| ... } ⇒ Object
Yields the input
record
serialized as TSV.
Methods inherited from Serializer
Methods inherited from Wukong::Processor
configure, description, #finalize, #perform_action, #receive_action, #setup, #stop
Methods included from Logging
Methods inherited from Hanuman::Stage
Methods included from Hanuman::StageClassMethods
#builder, #label, #register, #set_builder
Methods included from Hanuman::StageInstanceMethods
#add_stage_link, #linkable_name, #root
Instance Method Details
#process(record) {|tsv| ... } ⇒ Object
Yields the input record
serialized as TSV.
107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/wukong/widget/serializers.rb', line 107 def process(record) if record.respond_to?(:to_tsv) tsv = record.to_tsv else wire_format = record.try(:to_wire) || record raise SerializerError.new("Record must be in Array format to be serialized as TSV") unless wire_format.respond_to?(:map) tsv = wire_format.map(&:to_s).join("\t") end yield tsv rescue => e handle_error(record, e) end |