lib/dbf/table.rb in dbf-3.1.2 vs lib/dbf/table.rb in dbf-3.1.3

- old
+ new

@@ -209,17 +209,16 @@ private def build_columns # :nodoc: safe_seek do @data.seek(DBF_HEADER_SIZE) - columns = [] - until end_of_record? - column_data = @data.read(DBF_HEADER_SIZE) - name, type, length, decimal = column_data.unpack('a10 x a x4 C2') - columns << Column.new(self, name, type, length, decimal) + [].tap do |columns| + until end_of_record? + column_data = @data.read(DBF_HEADER_SIZE) + columns << Column.new(self, *column_data.unpack('a10 x a x4 C2')) + end end - columns end end def deleted_record? # :nodoc: flag = @data.read(1) @@ -229,16 +228,15 @@ def end_of_record? # :nodoc: safe_seek { @data.read(1).ord == 13 } end def find_all(options) # :nodoc: - map do |record| - if record && record.match?(options) - yield record if block_given? - record - end - end.compact + select do |record| + next unless record && record.match?(options) + yield record if block_given? + record + end end def find_first(options) # :nodoc: detect { |record| record && record.match?(options) } end @@ -248,10 +246,10 @@ end def header # :nodoc: @header ||= safe_seek do @data.seek(0) - Header.new(@data.read DBF_HEADER_SIZE) + Header.new(@data.read(DBF_HEADER_SIZE)) end end def memo_class # :nodoc: @memo_class ||= begin