def scale_widths(widths, opts = {})
      return widths unless opts[:width]

      row_width = widths.inject(:+)

      return widths if !opts[:expand] && row_width <= opts[:width]

      scale = 1.0*opts[:width]/row_width
      widths.map { |width| (scale * width).round }
    end
def scale_widths(widths, opts = {})
      return widths unless opts[:width]

      row_width = widths.inject(:+)

      return widths if !opts[:expand] && row_width <= opts[:width]

      scale = 1.0*opts[:width]/row_width
      widths.map { |width| (scale * width).round }
    end
Scales the widths in regard to opts[:width] and opts[:expand]. If
 :expand is true and :width is set the rows are expanded to the
 :width if the rows are shorter than width. If the rows are
 larger than :width the rows are scaled to not exceed the
 :width. If :width is not set the rows are not scaled.