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.



474
475
476
# File 'lib/zyps.rb', line 474

def initialize
	reset_elapsed_time
end

Instance Method Details

#copyObject

Make a deep copy.



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

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).



482
483
484
485
486
487
# File 'lib/zyps.rb', line 482

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

#reset_elapsed_timeObject



489
490
491
# File 'lib/zyps.rb', line 489

def reset_elapsed_time
	@last_check_time = Time.new.to_f
end