Class: Zyps::Clock

Inherits:
Object
  • Object
show all
Defined in:
lib/zyps.rb

Overview

A clock to use for timing actions.

Instance Method Summary collapse

Constructor Details

#initializeClock

Returns a new instance of Clock.



513
514
515
# File 'lib/zyps.rb', line 513

def initialize
	reset_elapsed_time
end

Instance Method Details

#copyObject

Make a deep copy.



518
# File 'lib/zyps.rb', line 518

def copy; self.clone; end

#elapsed_timeObject

Returns the time in (fractional) seconds since this method was last called (or on the first call, time since the Clock was created).



521
522
523
524
525
526
# File 'lib/zyps.rb', line 521

def elapsed_time
	time = Time.new.to_f
	elapsed_time = time - @last_check_time
	@last_check_time = time
	elapsed_time
end

#reset_elapsed_timeObject



528
529
530
# File 'lib/zyps.rb', line 528

def reset_elapsed_time
	@last_check_time = Time.new.to_f
end