Skip to content

Commit

Permalink
fallback to 0.0 in case of no gutter, fixes prawnpdf#1343
Browse files Browse the repository at this point in the history
  • Loading branch information
afdev82 committed Mar 19, 2024
1 parent ce37403 commit 327de7e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/prawn/grid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ def subdivide(total, num, gutter)

def apply_gutter(options)
if options.key?(:gutter)
@gutter = Float(options[:gutter])
@gutter = Float(options[:gutter] || 0.0)

This comment has been minimized.

Copy link
@bvogel

bvogel Apr 8, 2024

this won't help as the first statement does not return nil but will raise an exception

This comment has been minimized.

Copy link
@afdev82

afdev82 Apr 11, 2024

Author

Hm... which statement? The exception is thrown by the Float function, if options[:gutter] is nil.
options[:gutter] || 0.0 is not nil and the Float function returns 0.0.
The code is working, because I am using it in my project instead of the upstream Prawn gem, to fix this issue.

@row_gutter = @gutter
@column_gutter = @gutter
else
@row_gutter = Float(options[:row_gutter])
@column_gutter = Float(options[:column_gutter])
@row_gutter = Float(options[:row_gutter] || 0.0)
@column_gutter = Float(options[:column_gutter] || 0.0)
@gutter = 0
end
end
Expand Down

0 comments on commit 327de7e

Please sign in to comment.