prawnpdf/prawn — pull request #639 by hbrandl (2014-01-15 19:58:04+00:00)
Title: Allowing for small arithmetic errors when calculating column widths

I found another bug in the table width calculation algorithm.

In some cases arithmetic errors lead to errors.

Testcase to illustrate the problem
```` ruby
it "table widths should be correctly calculated even for column widths with lots of decimals", :focus do
data=[["a", "b ", "c ", "d", "e", "f", "g", "h", "i", "j", "k", "l"],
[{:content=>"Foobar", :colspan=>12}]
]
#we need values with lots of decimals so that arithmetic errors will occur
#the values are not arbitrary but where found converting mm to pdf pt
column_widths=[137, 40, 40, 54.69291338582678, 54.69291338582678, 54.69291338582678, 54.69291338582678, 54.69291338582678, 54.69291338582678, 54.69291338582678, 54.69291338582678, 54.69291338582678]
pdf = Prawn::Document.new({:page_size => 'A4', :page_layout => :landscape})
table = Prawn::Table.new data, pdf, :column_widths => column_widths
table.column_widths.should == column_widths
end
````

Output of current master
```` ruby
1) Prawn::Table You can explicitly set the column widths and use a colspan > 1 table widths should be correctly calculated even for column widths with lots of decimals
Failure/Error: table.column_widths.should == column_widths
expected: [137, 40, 40, 54.69291338582678, 54.69291338582678, 54.69291338582678, 54.69291338582678, 54.69291338582678, 54.69291338582678, 54.69291338582678, 54.69291338582678, 54.69291338582678]
got: [59.10301837270342, 59.10301837270342, 59.10301837270342, 59.10301837270342, 59.10301837270342, 59.10301837270342, 59.10301837270342, 59.10301837270342, 59.10301837270342, 59.10301837270342, 59.10301837270342, 59.10301837270342] (using ==)
# ./spec/table_spec.rb:59:in `block (3 levels) in '
````

This pull request addresses the issue by allowing for an small arithmetic error (e-09) in the two affected algorithms.