module TimeTaken

Constants

VERSION

Public Class Methods

time_taken(format=:milli_seconds, &block) click to toggle source
# File lib/time_taken/time_taken.rb, line 5
def self.time_taken(format=:milli_seconds, &block)
        if block_given? && valid_format?(format)
                start_time = Time.now
                block.call 
                end_time = Time.now
                ((end_time - start_time) * @time_formats[format])
        else
                0
        end
end
valid_format?(format) click to toggle source
# File lib/time_taken/time_taken.rb, line 16
def self.valid_format? format 
        !@time_formats[format].nil?
end