Module: ShellTastic::Timer

Defined in:
lib/shelltastic/timer.rb

Class Method Summary collapse

Class Method Details

.startTime

Creates a start time object

Parameters:

  • (nil)

Returns:

  • (Time)

    Time now object



7
8
9
# File 'lib/shelltastic/timer.rb', line 7

def start
  @start = Time.now
end

.stopTime

Creates a stop time object

Parameters:

  • (nil)

Returns:

  • (Time)

    Time now object



14
15
16
# File 'lib/shelltastic/timer.rb', line 14

def stop
  @stop = Time.now
end

.total_time(milliseconds = false) ⇒ Time

Calculates the total time elapsed

Parameters:

  • opts (Hash, nil)

    the opts passed in

  • [Boolean] (Hash)

    a customizable set of options

Returns:

  • (Time)

    Time elapsed between #start and #stop

See Also:

  • and #stop


23
24
25
26
27
28
29
# File 'lib/shelltastic/timer.rb', line 23

def total_time(milliseconds = false)
  if milliseconds
    (@stop - @start) * 1000.0
  else
    @stop - @start
  end
end