【发布时间】:2014-01-27 14:38:12
【问题描述】:
这是我的方法:
def get_video_duration
@time ||= Panda.get("/videos/#{@video.panda_id}/metadata.json")["duration"]
format_duration
end
我需要将这个方法写得“更好”,用begin、rescue 块包装它,这样@time 可以为零,具体取决于API 的响应。
【问题讨论】:
-
您是要始终执行
Panda.get,还是仅在@time为nil/false 时执行?