Class: ShellTastic::Timer
- Inherits:
-
Object
- Object
- ShellTastic::Timer
- Defined in:
- lib/shelltastic/timer.rb
Instance Method Summary collapse
-
#initialize ⇒ Timer
constructor
A new instance of Timer.
-
#start ⇒ Time
Creates a start time object.
-
#stop ⇒ Time
Creates a stop time object.
-
#total_time(milliseconds = false) ⇒ Time
Calculates the total time elapsed.
Constructor Details
#initialize ⇒ Timer
Returns a new instance of Timer.
3 4 5 |
# File 'lib/shelltastic/timer.rb', line 3 def initialize end |
Instance Method Details
#start ⇒ Time
Creates a start time object
10 11 12 |
# File 'lib/shelltastic/timer.rb', line 10 def start @start_time = Time.now end |
#stop ⇒ Time
Creates a stop time object
17 18 19 |
# File 'lib/shelltastic/timer.rb', line 17 def stop @stop_time = Time.now end |
#total_time(milliseconds = false) ⇒ Time
Calculates the total time elapsed
26 27 28 29 30 31 32 |
# File 'lib/shelltastic/timer.rb', line 26 def total_time(milliseconds = false) if milliseconds (@stop_time - @start_time) * 1000.0 else @stop_time - @start_time end end |