<commit_before>require 'csv'

module AsCSV
  class CSVBuilder
    attr_reader :records, :options

    def initialize(records, options={})
      @records = Array(records)
      @options = options
      @options[:csv_options] ||= {}
      validate
    end

    def to_csv
      rows.collect { |row| CSV.generate_line row, @options[:csv_options] }.join
    end

    private

      def rows
        @rows ||= [headers] + data_rows
      end

      def headers<commit_msg>yank csv_options entirely so as to eliminate fear of unintended consequences<commit_after>require 'csv'

module AsCSV
  class CSVBuilder
    attr_reader :records, :options, :csv_options

    def initialize(records, options={})
      @records = Array(records)
      @options = options
      @csv_options = options.delete(:csv_options) || {}
      validate
    end

    def to_csv
      rows.collect { |row| CSV.generate_line row, csv_options }.join
    end

    private

      def rows
        @rows ||= [headers] + data_rows
      end

      def headers
{'fraction_non_alphanumeric': 0.09313725490196079, 'fraction_numerical': 0.0, 'mean_word_length': 2.607773851590106, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5868268', 'n_tokens_mistral': 314, 'n_tokens_neox': 295, 'n_words': 85}