class Time
Public Class Methods
duration_of() { || ... }
click to toggle source
The total time (in seconds) for the block to complete.
Example:
>> Time.duration_of { sleep 2 } => 2.000000000000001
# File lib/freshen/helpers/time.rb, line 8 def self.duration_of(&block) return nil unless block_given? start_time = Time.now yield end_time = Time.now end_time.to_f - start_time.to_f end