Sha256: d103ff22e54ea1988ce230f260d9a563ddccfc9a5623561b8a5ef6efcf81bce9

Contents?: true

Size: 438 Bytes

Versions: 3

Compression:

Stored size: 438 Bytes

Contents

require 'module_extensions'

# == Synopsis
# Various extensions to the Kernel class
# Note, uses the Module.my_extension method to only add the method if
# it doesn't already exist.
module Kernel
  my_extension("timer") do
    # == Synopsis
    # a simple elapse time for the give block
    # == Usage
    # elapse_seconds = timer {...}
    def timer
      start_time = Time.now
      yield
      Time.now - start_time
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
royw-roys_extensions-0.0.2 lib/kernel_extensions.rb
royw-roys_extensions-0.0.3 lib/kernel_extensions.rb
royw-roys_extensions-0.0.4 lib/kernel_extensions.rb