lib/worksheet.rb in rxl-0.1.4 vs lib/worksheet.rb in rxl-0.2.0
- old
+ new
@@ -72,10 +72,11 @@
def self.hash_worksheet_to_hash_table(raw_hash)
cells = Mitrush.deep_copy(raw_hash)
columns = cells.keys.map { |key| key[/\D+/] }.uniq
columns.delete_if { |item| cells["#{item}1"][:value].nil? }
- row_nums = cells.keys.map { |key| key[/\d+/].to_i }.uniq[1..-1].sort
+ row_nums = cells.keys.map { |key| key[/\d+/].to_i }.uniq[1..-1] || []
+ row_nums.sort! unless row_nums.empty?
row_nums.map do |row_number|
columns.each_with_object({}) do |column_letter, h|
h[cells["#{column_letter}1"][:value]] = cells["#{column_letter}#{row_number}"][:value]
end
end
\ No newline at end of file