class Nocode::Steps::Serialize::Csv
Take the contents of a register and create a CSV out of its contents. The CSV contents will override the register specified.
Public Instance Methods
perform()
click to toggle source
# File lib/nocode/steps/serialize/csv.rb, line 11 def perform input = registers[register_option] registers[register_option] = CSV.generate do |csv| array(input).each_with_index do |object, index| csv << object.keys if index.zero? && object.respond_to?(:keys) add_object(object, csv) end end end
Private Instance Methods
add_object(object, csv)
click to toggle source
# File lib/nocode/steps/serialize/csv.rb, line 25 def add_object(object, csv) object ||= {} if object.is_a?(Array) csv << object elsif object.respond_to?(:values) csv << object.values end end