gpt4 book ai didi

ruby-on-rails - Ruby prawn-table gem : How to select last row of a table?

转载 作者:行者123 更新时间:2023-12-04 06:05:32 28 4
gpt4 key购买 nike

我有一个如下所示的 Prawn table :

table info_rows do
row(0).font_style = :bold
row(0).align = :center
row(0).borders = [:top, :bottom, :left, :right]
row(1..50).borders = [:left, :right]
self.header = true
self.row_colors = ['EEEEEE', 'FFFFFF']
self.column_widths = col_sizes
end

我需要在最后一行放置一个底部边框,但不确定如何检测循环内的最后一行?类似的东西(循环内的以下 if 语句显然不起作用/只是示例)...
table info_rows do
row(0).font_style = :bold
row(0).align = :center
row(0).borders = [:top, :bottom, :left, :right]
row(1..50).borders = [:left, :right]

if row.last
?(?).borders = [:bottom, :left, :right]
end

self.header = true
self.row_colors = ['EEEEEE', 'FFFFFF']
self.column_widths = col_sizes
end

任何想法都是最受欢迎的。

我正在使用 Ruby - 2.1.2

最佳答案

你可以试试这个:

table info_rows do
row(0).font_style = :bold
row(0).align = :center
row(0).borders = [:top, :bottom, :left, :right]
row(1..50).borders = [:left, :right]
row(-1).borders = [:bottom, :left, :right]

self.header = true
self.row_colors = ['EEEEEE', 'FFFFFF']
self.column_widths = col_sizes
end

关于ruby-on-rails - Ruby prawn-table gem : How to select last row of a table?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28951676/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com