Sha256: 858886e3a8168e45aae5555fccc7360dbe3c99b1fc6aee5820263eac8689d9ab

Contents?: true

Size: 836 Bytes

Versions: 1

Compression:

Stored size: 836 Bytes

Contents

module DataForge
  module File
    module CSV
      class CSVRecordFileDefinition

        class << self
          include DataForge::DSL::Attributes
        end

        attr_reader :name, :fields
        define_attribute :file_name
        define_attribute :delimiter
        define_attribute :quote
        define_attribute :encoding
        define_attribute :has_header_row

        alias :separator :delimiter



        def initialize(name)
          @name = name
          @file_name = "#{name.to_s}.csv"
          @fields = {}
          @delimiter = ","
          @quote = '"'
          @encoding = "UTF-8"
          @has_header_row = true
        end



        def field(name, type = String)
          @fields[name] = type
        end



        def field_names
          @fields.keys
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
data_forge-0.1 lib/data_forge/file/csv/csv_record_file_definition.rb