Skip to content

Commit e361d6f

Browse files
maciejmajewskipythonicrubyist
authored andcommitted
Fix converting values formatted as percentage (#33)
Values formatted as percentage values should not be divided by 100. They are already stored as decimals (0.15 for 15%).
1 parent 545e303 commit e361d6f

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

lib/creek/styles/converter.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,8 @@ def self.call(value, type, style, options = {})
5858
value
5959
when :fixnum
6060
value.to_i
61-
when :float
61+
when :float, :percentage
6262
value.to_f
63-
when :percentage
64-
value.to_f / 100
6563
when :date, :time, :date_time
6664
convert_date(value, options)
6765
when :bignum

spec/fixtures/sample.xlsx

235 Bytes
Binary file not shown.

spec/test_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
{'A4'=>'Content 7', 'B4'=>'Content 8', 'C4'=>'Content 9', 'D4'=>'Content 10', 'E4'=>'Content 11', 'F4'=>'Content 12'},
3333
{'A5'=>nil, 'B5'=>nil, 'C5'=>nil, 'D5'=>nil, 'E5'=>nil, 'F5'=>nil, 'G5'=>nil, 'H5'=>nil, 'I5'=>nil, 'J5'=>nil, 'K5'=>nil, 'L5'=>nil, 'M5'=>nil, 'N5'=>nil, 'O5'=>nil, 'P5'=>nil, 'Q5'=>nil, 'R5'=>nil, 'S5'=>nil, 'T5'=>nil, 'U5'=>nil, 'V5'=>nil, 'W5'=>nil, 'X5'=>nil, 'Y5'=>nil, 'Z5'=>'Z Content', 'AA5'=>nil, 'AB5'=>nil, 'AC5'=>nil, 'AD5'=>nil, 'AE5'=>nil, 'AF5'=>nil, 'AG5'=>nil, 'AH5'=>nil, 'AI5'=>nil, 'AJ5'=>nil, 'AK5'=>nil, 'AL5'=>nil, 'AM5'=>nil, 'AN5'=>nil, 'AO5'=>nil, 'AP5'=>nil, 'AQ5'=>nil, 'AR5'=>nil, 'AS5'=>nil, 'AT5'=>nil, 'AU5'=>nil, 'AV5'=>nil, 'AW5'=>nil, 'AX5'=>nil, 'AY5'=>nil, 'AZ5'=>'Content 13'},
3434
{'A6'=>'1', 'B6'=>'2', 'C6'=>'3'}, {'A7'=>'Content 15', 'B7'=>'Content 16', 'C7'=>'Content 18', 'D7'=>'Content 19'},
35-
{'A8'=>nil, 'B8'=>'Content 20', 'C8'=>nil, 'D8'=>nil, 'E8'=>nil, 'F8'=>'Content 21'}]
35+
{'A8'=>nil, 'B8'=>'Content 20', 'C8'=>nil, 'D8'=>nil, 'E8'=>nil, 'F8'=>'Content 21'},
36+
{'A10' => 0.15, 'B10' => 0.15}]
3637
end
3738

3839
after(:all) do
@@ -67,7 +68,8 @@
6768
rows[5].should == @expected_rows[5]
6869
rows[6].should == @expected_rows[6]
6970
rows[7].should == @expected_rows[7]
70-
row_count.should == 8
71+
rows[8].should == @expected_rows[8]
72+
row_count.should == 9
7173
end
7274

7375
it 'Parse rows with empty cells and meta data successfully.' do

0 commit comments

Comments
 (0)