lib/prawn/table/cells.rb in prawn-0.14.0 vs lib/prawn/table/cells.rb in prawn-0.15.0

- old
+ new

@@ -6,11 +6,10 @@ # # This is free software. Please see the LICENSE and COPYING files for details. module Prawn class Table - # Selects the given rows (0-based) for styling. Returns a Cells object -- # see the documentation on Cells for things you can do with cells. # def rows(row_spec) cells.rows(row_spec) @@ -36,10 +35,12 @@ # # table.rows(1..3).columns(2..4).background_color = 'ff0000' # class Cells < Array + # @group Experimental API + # Limits selection to the given row or rows. +row_spec+ can be anything # that responds to the === operator selecting a set of 0-based row # numbers; most commonly a number or a range. # # table.row(0) # selects first row @@ -252,10 +253,14 @@ old_sum += values[index+i] unless values[index+i].nil? } #calculate future return value new_sum = cell.send(meth) * cell.colspan - spanned_width_needs_fixing = (new_sum > old_sum) + + #due to float rounding errors we need to ignore a small difference in the new + #and the old sum the same had to be done in + #the column_width_calculator#natural_width + spanned_width_needs_fixing = ((new_sum - old_sum) > Prawn::FLOAT_PRECISION) if spanned_width_needs_fixing #not entirely sure why we need this line, but with it the tests pass values[index] = [values[index], cell.send(meth)].compact.send(aggregate) #overwrite the old values with the new ones, but only if all entries existed