lib/dbf/table.rb in dbf-1.6.5 vs lib/dbf/table.rb in dbf-1.6.6

- old
+ new

@@ -166,21 +166,17 @@ end end # Retrieves column information from the database def columns - column_class = FOXPRO_VERSIONS.include?(version) ? FoxproColumn : Column - @columns ||= begin - column_count = (@header_length - DBF_HEADER_SIZE + 1) / DBF_HEADER_SIZE - @data.seek(DBF_HEADER_SIZE) columns = [] column_count.times do name, type, length, decimal = @data.read(32).unpack('a10 x a x4 C2') if length > 0 - columns << column_class.new(name.strip, type, length, decimal, @encoding) + columns << column_class.new(name.strip, type, length, decimal, version, @encoding) end end columns end end @@ -188,9 +184,17 @@ def supports_encoding? "".respond_to? :encoding end private + + def column_class + @column_class ||= FOXPRO_VERSIONS.include?(version) ? FoxproColumn : Column + end + + def column_count + @column_count ||= (@header_length - DBF_HEADER_SIZE + 1) / DBF_HEADER_SIZE + end def open_memo(path) #nodoc files = Dir.glob("#{File.dirname(path)}/#{File.basename(path, '.*')}*.{fpt,FPT,dbt,DBT}") files.any? ? Memo.open(files.first, version) : nil end