Browse Source

fix save_sheet to calculate rows correctly based on range

Based on PR #207
dev
Clarence Sparr Risher 8 years ago committed by Andy Meneely
parent
commit
2a86b8f215
  1. 10
      lib/squib/args/sheet.rb
  2. 5
      spec/data/samples/data/_excel.rb.txt

10
lib/squib/args/sheet.rb

@ -40,6 +40,7 @@ module Squib
trim_radius: 38,
trim: 0,
width: 3300,
range: :all,
rtl: false,
}
end
@ -80,9 +81,14 @@ module Squib
def validate_rows(arg)
raise 'columns must be an integer' unless columns.respond_to? :to_i
return 1 if @deck_size < columns
count = if range == :all
@deck_size
else
count = range.to_a.length
end
return 1 if count <= columns
return arg if arg.respond_to? :to_i
(@deck_size.to_i / columns.to_i).ceil
(count.to_f / columns.to_f).ceil
end
def full_filename

5
spec/data/samples/data/_excel.rb.txt

@ -692,10 +692,9 @@ cairo: set_source([MockDouble, 300, 0])
cairo: paint([])
cairo: set_source([MockDouble, 400, 0])
cairo: paint([])
surface: write_to_png(["_output/sample_excel_resources_00.png"])
cairo: set_source([MockDouble, 0, 0])
cairo: set_source([MockDouble, 0, 101])
cairo: paint([])
surface: write_to_png(["_output/sample_excel_resources_01.png"])
surface: write_to_png(["_output/sample_excel_resources_00.png"])
surface: finish([])
surface: finish([])
surface: finish([])

Loading…
Cancel
Save