# File lib/asciidoctor/table.rb, line 104 def assign_column_widths width_base = nil pf = 10.0 ** 4 # precision factor (multipler / divisor) for managing precision of calculated result total_width = col_pcwidth = 0 if width_base @columns.each {|col| total_width += (col_pcwidth = col.assign_width nil, width_base, pf) } else col_pcwidth = ((100 * pf / @columns.size).to_i) / pf # or... #col_pcwidth = (100.0 / @columns.size).truncate 4 col_pcwidth = col_pcwidth.to_i if col_pcwidth.to_i == col_pcwidth @columns.each {|col| total_width += col.assign_width col_pcwidth } end # donate balance, if any, to final column (using half up rounding) unless total_width == 100 @columns[-1].assign_width(((100 - total_width + col_pcwidth) * pf).round / pf) # or (manual half up rounding)... #numerator = (raw_numerator = (100 - total_width + col_pcwidth) * pf).to_i #numerator += 1 if raw_numerator >= numerator + 0.5 #@columns[-1].assign_width numerator / pf # or... #@columns[-1].assign_width((100 - total_width + col_pcwidth).round 4) end nil end