Sha256: 2a3fcb18556c5ffa87bff765073bd12b2ed9114947f44fd1c4289290b3f84174

Contents?: true

Size: 1.32 KB

Versions: 18

Compression:

Stored size: 1.32 KB

Contents

module ActiveList

  module Exporters

    class AbstractExporter

      attr_reader :table, :generator

      def initialize(generator)
        @generator = generator
        @table = generator.table
      end

      def file_extension
        "txt"
      end

      def mime_type
        Mime::TEXT
      end

      def send_data_code
        raise NotImplementedError, "#{self.class.name}#format_data_code is not implemented."
      end

      def columns_headers(options={})
        headers, columns = [], table.exportable_columns
        for column in columns
          datum = column.header_code
          headers << (options[:encoding] ? datum+".to_s.encode('#{options[:encoding]}')" : datum)
        end
        return headers
      end

      def columns_to_array(nature, options={})
        columns = table.exportable_columns

        array = []
        record = options[:record] || 'record_of_the_death'
        for column in columns
          if column.is_a?(ActiveList::Definition::AbstractColumn)
            if nature == :header
              datum = column.header_code
            else
              datum = column.exporting_datum_code(record)
            end
            array << (options[:encoding] ? datum+".to_s.encode('#{options[:encoding]}')" : datum)
          end
        end
        return array
      end

    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
active_list-6.4.1 lib/active_list/exporters/abstract_exporter.rb
active_list-6.4.0 lib/active_list/exporters/abstract_exporter.rb
active_list-6.3.1 lib/active_list/exporters/abstract_exporter.rb
active_list-6.3.0 lib/active_list/exporters/abstract_exporter.rb
active_list-6.2.4 lib/active_list/exporters/abstract_exporter.rb
active_list-6.2.3 lib/active_list/exporters/abstract_exporter.rb
active_list-6.2.1 lib/active_list/exporters/abstract_exporter.rb
active_list-6.2.0 lib/active_list/exporters/abstract_exporter.rb
active_list-6.1.5 lib/active_list/exporters/abstract_exporter.rb
active_list-6.1.4 lib/active_list/exporters/abstract_exporter.rb
active_list-6.1.3 lib/active_list/exporters/abstract_exporter.rb
active_list-6.1.2 lib/active_list/exporters/abstract_exporter.rb
active_list-6.1.1 lib/active_list/exporters/abstract_exporter.rb
active_list-6.1.0 lib/active_list/exporters/abstract_exporter.rb
active_list-6.0.1 lib/active_list/exporters/abstract_exporter.rb
active_list-6.0.0 lib/active_list/exporters/abstract_exporter.rb
active-list-5.0.1 lib/active_list/exporters/abstract_exporter.rb
active-list-5.0.0 lib/active_list/exporters/abstract_exporter.rb