Sha256: 07f3990ddbe0bad1077eeb26cbd476073e6861f1da49a6027e1644417eeea86a

Contents?: true

Size: 784 Bytes

Versions: 1

Compression:

Stored size: 784 Bytes

Contents

module ShellTastic
  module Timer
    class << self
      # Creates a start time object
      # @param [nil] 
      # @return [Time] Time now object
      def start
        @start = Time.now
      end
      
      # Creates a stop time object
      # @param [nil] 
      # @return [Time] Time now object
      def stop
        @stop = Time.now
      end

      # Calculates the total time elapsed
      # @see #start and #stop
      # @param [Hash, nil] opts the opts passed in
      # @option [Boolean] milliseconds the time in milliseconds
      # @return [Time] Time elapsed between #start and #stop
      def total_time(milliseconds = false)
        if milliseconds
          (@stop - @start) * 1000.0
        else
          @stop - @start
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shelltastic-0.2.5 lib/shelltastic/timer.rb