Sha256: 7d81f9ed840c5f21e55cdd76066b8bcdbe6e1f60602c290d67d26056fa10e2df

Contents?: true

Size: 1.01 KB

Versions: 9

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Decidim
  module TermCustomizer
    module Import
      module Readers
        # Imports an exported file to data arrays that can be processed during
        # yields.
        class Base
          def initialize(file)
            @file = file
          end

          # The read_rows method should iterate over each row of the data and
          # yield the data array of each row with the row's index. For example,
          # this could look like following:
          #   Parser.read(file).rows.each_with_index do |row, index|
          #     yield row.to_a, index
          #   end
          #
          # The first row yielded with index 0 needs to contain the data headers
          # which can be later used to map the data to correct attributes.
          #
          # This needs to be implemented by the extending classes.
          def read_rows
            raise NotImplementedError
          end

          protected

          attr_reader :file
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
decidim-term_customizer-0.23.0 lib/decidim/term_customizer/import/readers/base.rb
decidim-term_customizer-0.22.0 lib/decidim/term_customizer/import/readers/base.rb
decidim-term_customizer-0.21.0 lib/decidim/term_customizer/import/readers/base.rb
decidim-term_customizer-0.20.0 lib/decidim/term_customizer/import/readers/base.rb
decidim-term_customizer-0.19.1 lib/decidim/term_customizer/import/readers/base.rb
decidim-term_customizer-0.19.0 lib/decidim/term_customizer/import/readers/base.rb
decidim-term_customizer-0.18.0 lib/decidim/term_customizer/import/readers/base.rb
decidim-term_customizer-0.17.1 lib/decidim/term_customizer/import/readers/base.rb
decidim-term_customizer-0.17.0 lib/decidim/term_customizer/import/readers/base.rb