Sha256: b4f3c53df8082def2f32245fe6bc971adf0ac725cb4af37ed781e9e95cbbb495

Contents?: true

Size: 459 Bytes

Versions: 4

Compression:

Stored size: 459 Bytes

Contents

module Para
  module Importer
    class Base
      attr_reader :sheet

      def initialize(file)
        @sheet = Roo::Spreadsheet.open(file.path)
      end

      def run
        ActiveRecord::Base.transaction do
          (2..(sheet.last_row)).each do |index|
            import_from_row(sheet.row(index))
          end
        end
      end

      def import_from_row(row)
        raise '#import_from_row(row) must be defined'
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
para-0.5.4 lib/para/importer/base.rb
para-0.5.3 lib/para/importer/base.rb
para-0.5.1 lib/para/importer/base.rb
para-0.5.0 lib/para/importer/base.rb