Sha256: 106b265d61254fb10d079b4c0685d83e2d83eb2e24ddc2580e2b768ea785420a

Contents?: true

Size: 458 Bytes

Versions: 3

Compression:

Stored size: 458 Bytes

Contents

module Squib
  module Import
    module QuantityExploder
      def explode_quantities(data, qty)
        return data unless data.col? qty.to_s.strip
        qtys = data[qty]
        new_data = Squib::DataFrame.new
        data.each do |col, arr|
          new_data[col] = []
          qtys.each_with_index do |qty, index|
            qty.to_i.times { new_data[col] << arr[index] }
          end
        end
        return new_data
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
squib-0.19.0 lib/squib/import/quantity_exploder.rb
squib-0.19.0b lib/squib/import/quantity_exploder.rb
squib-0.19.0a lib/squib/import/quantity_exploder.rb