lib/rubygame/clock.rb in rubygame-2.5.2 vs lib/rubygame/clock.rb in rubygame-2.5.3
- old
+ new
@@ -220,12 +220,15 @@
#
# Return the actual framerate (frames per second) recorded by the
# Clock. See #tick.
#
def framerate
- 1000.0 * @samples.length / @samples.inject(0){|sum, n| sum + n}
- rescue ZeroDivisionError
- 0.0
+ sum = @samples.inject(0){|sum, n| sum + n}
+ if sum == 0
+ return 0.0
+ else
+ 1000.0 * @samples.length / sum
+ end
end
# call-seq:
# frametime -> Float