我被困在这里:
puts "#{percent_finished.round}% uploading complete" ? if/unless ...
答案 0 :(得分:1)
如果percent_finished
是ActiveRecord模型的一部分,您实际上只需拨打percent_finished_changed?
即可。
例如:
puts "#{percent_finished.round}% uploading complete" if percent_finished_changed?
以下是一些文档:
答案 1 :(得分:1)
这是一个命令行工具吗?
last_percent = nil
upload_loop do
# ...
percent_rounded = percent_finished.round
puts "#{percent_rounded}% uploading complete" if percent_rounded != last_percent
last_percent = percent_rounded
end