Skip to content

Commit c7905b7

Browse files
vividtoneishikawa999
authored andcommitted
Use sum instead of inject(0, :+) (#34153).
Patch by Go MAEDA. git-svn-id: http://svn.redmine.org/redmine/trunk@20173 e93f8b46-1217-0410-a6f0-8f06a7374b81
1 parent 5d4821e commit c7905b7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/redmine/export/pdf/issues_pdf_helper.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,13 @@ def issues_to_pdf(issues, project, query)
276276
col_width = []
277277
unless query.inline_columns.empty?
278278
col_width = calc_col_width(issues, query, table_width, pdf)
279-
table_width = col_width.inject(0, :+)
279+
table_width = col_width.sum
280280
end
281281

282282
# use full width if the query has block columns (description, last_notes or full width custom fieds)
283283
if table_width > 0 && query.block_columns.any?
284284
col_width = col_width.map {|w| w * (page_width - right_margin - left_margin) / table_width}
285-
table_width = col_width.inject(0, :+)
285+
table_width = col_width.sum
286286
end
287287

288288
# title
@@ -418,7 +418,7 @@ def calc_col_width(issues, query, table_width, pdf)
418418
if table_width > col_min * col_width_avg.length
419419
table_width -= col_min * col_width_avg.length
420420
else
421-
ratio = table_width / col_width_avg.inject(0, :+)
421+
ratio = table_width / col_width_avg.sum
422422
return col_width = col_width_avg.map {|w| w * ratio}
423423
end
424424
end
@@ -451,11 +451,11 @@ def calc_col_width(issues, query, table_width, pdf)
451451
col_width_avg.map! {|x| x / k}
452452

453453
# calculate columns width
454-
ratio = table_width / col_width_avg.inject(0, :+)
454+
ratio = table_width / col_width_avg.sum
455455
col_width = col_width_avg.map {|w| w * ratio}
456456

457457
# correct max word width if too many columns
458-
ratio = table_width / word_width_max.inject(0, :+)
458+
ratio = table_width / word_width_max.sum
459459
word_width_max.map! {|v| v * ratio} if ratio < 1
460460

461461
# correct and lock width of some columns
@@ -479,7 +479,7 @@ def calc_col_width(issues, query, table_width, pdf)
479479
while done == 0
480480
# calculate free & locked columns width
481481
done = 1
482-
ratio = table_width / col_width.inject(0, :+)
482+
ratio = table_width / col_width.sum
483483

484484
# correct columns width
485485
col_width.each_with_index do |w,i|
@@ -500,7 +500,7 @@ def calc_col_width(issues, query, table_width, pdf)
500500
end
501501
end
502502

503-
ratio = table_width / col_width.inject(0, :+)
503+
ratio = table_width / col_width.sum
504504
col_width.map! {|v| v * ratio + col_min}
505505
col_width
506506
end

0 commit comments

Comments
 (0)